python - Django, adding multiple databases miscofigured my settings -


i had working test project used 1 database (django 1.8 + postgresql 9.1). then, asked add multiple databases. dropped 1 database using , created 3 new ones. modified settings.py this:

databases = {     'default': {         'engine': 'django.db.backends.postgresql_psycopg2',         'name': 'core',         'user': 'chris',         'password': '***',         'host': 'localhost',         'port': '5432',     },     'db1': {         'engine': 'django.db.backends.postgresql_psycopg2',         'name': 'db1',         'user': 'chris',         'password': '***',         'host': 'localhost',         'port': '5432',         },     'db2': {         'engine': 'django.db.backends.postgresql_psycopg2',         'name': 'db2',         'user': 'chris',         'password': '***',         'host': 'localhost',         'port': '5432',     } } default_index_tablespace = 'default' 

(using automatic database routing , 1 models.py)

when try make first migrations this:

django-admin.py makemigrations --database=db1

django.core.exceptions.improperlyconfigured: requested setting default_index_tablespace, settings not configured. must either define environment variable django_settings_module or call settings.configure() before accessing settings.

but this:

(testproject) chris@ubuntu-pc ~/d/w/testproject> python manage.py shell >>> django.conf import settings >>> settings.default_index_tablespace 'default' >>> settings.configure() runtimeerror: settings configured. 

what doing wrong?

you should use manage.py inside project instead of django-admin.py:

python manage.py makemigrations 

you don't need pass database names makemigrations. need migrate each database separately while migrating.

python manage.py migrate --database=db1 

Comments

Popular posts from this blog

ruby - Trying to change last to "x"s to 23 -

jquery - Clone last and append item to closest class -

css - Can I use the :after pseudo-element on an input field? -