[PYTHON] How to specify a schema in Django's database settings

Django:1.10

Specify the schema name in OPTIONS of DATABASES in settings.py.

settings.py


DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql_psycopg2',
        'NAME': 'testdb',
        'USER': 'testuser',
        'PASSWORD': 'testpassword',
        'HOST': 'localhost',
        'PORT': '5432',
        'OPTIONS': {
            'options': '-c search_path=schema_name'
        },
    }
}

Recommended Posts

How to specify a schema in Django's database settings
A story about how to specify a relative path in python.
How to specify a .py file to load at startup in IPython 0.13
How to get a stacktrace in python
How to specify non-check target in Flake8
How to view images in Django's Admin
How to specify a .ui file in the dialog / widget GUI in PySide
How to clear tuples in a list (Python)
How to embed a variable in a python string
How to create a JSON file in Python
How to implement a gradient picker in Houdini
How to specify TLS version in python requests
How to pass settings to Item Pipeline in Scrapy
How to notify a Discord channel in Python
[Python] How to draw a histogram in Matplotlib
How to create a Rest Api in Django
How to write a named tuple document in 2020
How to count numbers in a specific range
How to read a file in a different directory
How to Mock a Public function in Pytest
If you specify a foreign key in Django's model change, you need to specify on_delete.
How to convert / restore a string with [] in python
How to get a logged-in user with Django's forms.py
[Python] How to expand variables in a character string
A memorandum on how to use keras.preprocessing.image in Keras
How to use the exists clause in Django's queryset
How to display DataFrame as a table in Markdown
How to execute a command using subprocess in Python
How to pass matplotlib backend settings in environment variables
How to reference static files in a Django project
[Linux] How to put your IP in a variable
How to call a function
How to hack a terminal
How to use Django's GeoIp2
How to develop in Python
How to slice a block multiple array from a multiple array in Python
How to import NoteBook as a module in Jupyter (IPython)
How to output a document in pdf format with Sphinx
How to use the __call__ method in a Python class
How to import a file anywhere you like in Python
How to specify a public directory Python simple HTTP server
How to temporarily implement a progress bar in a scripting language
How to define multiple variables in a python for statement
How to set the html class attribute in Django's forms.py
A note on how to load a virtual environment in PyCharm
I tried "How to get a method decorated in Python"
How to develop in a virtual environment of Python [Memo]
How to specify Cache-Control for blob storage in Azure Storage in Python
How to generate a query using the IN operator in Django
How to check if a value exists in an enum
How to get the last (last) value in a list in Python
How to specify command line arguments when debugging in PyCharm
How to get a list of built-in exceptions in python
Notes on how to use marshmallow in the schema library
How to import NoteBook as a module in Jupyter (IPython)
Data science companion in python, how to specify elements in pandas
How to get a quadratic array of squares in a spiral!
How to display a specified column of files in Linux (awk)
How to make a Japanese-English translation
How to write a Python class
[Python] How to do PCA in Python