Skip to content Skip to sidebar Skip to footer

Django Fails To Create Superuser In Other Db Than 'default'

Is it a bug or am I wrong ? I am at the step to create a superuser, but django want a table in wrong db despite my router seems to work : settings.py DATABASES = { 'intern_db

Solution 1:

The thing is the system is somewhat broken : it respects the config for some task but not for others (the 2 first "TRUE" in the output) but it doesn't for other and use default.

This is perhaps intended even if weird (actually nothing forbid to have several admin db, and that permits not have automatic dark choices).

Actually to create the SU in another db, and for any usage of these command, you must pass the database where you want to create it explicitly :

./manage.py createsuperuser --database=intern_db

NOTE : the db name is the alias in the config.

Solution 2:

You need to make migrations to your database before creating a superuser. To make migrations

user@root:~$python manage.py migrate

This will create the auth_user table in your database.

Post a Comment for "Django Fails To Create Superuser In Other Db Than 'default'"