Opened 5 years ago

Closed 5 years ago

#17327 closed New feature (fixed)

contrib.auth management commands ignores --database option

Reported by: skam <massimo.scamarcia@…> Owned by: Brian Riley
Component: contrib.auth Version: 1.3
Severity: Release blocker Keywords: django db models createsuperuser management
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

I am using multiple database support with a database router to switch the current database to provide different data based on the current request. I need also to separate user tables for each db and create a superuser for it, but createsuperuser management command ignores the "--database" option that I use often with "syncdb" and migration tools such as South:

$ python manage.py createsuperuser --database="test_database"
Usage: manage.py createsuperuser [options] 

Used to create a superuser.

manage.py: error: no such option: --database

Attachments (3)

createsuperuser-database-option.diff (5.6 KB) - added by Brian Riley 5 years ago.
auth-management-commands-database-option.diff (11.6 KB) - added by Brian Riley 5 years ago.
Patch to add --database option to both createsuperuser and change password management commands
createsuperuser-multidb-tests-moved.diff (5.3 KB) - added by Brian Riley 5 years ago.
Moves multi DB tests for createsuperuser to regressiontests

Download all attachments as: .zip

Change History (13)

comment:1 Changed 5 years ago by Preston Holmes

Component: Core (Management commands)contrib.auth
Summary: createsuperuser management command ignores --database optioncontrib.auth management commands ignores --database option
Triage Stage: UnreviewedAccepted
Type: UncategorizedNew feature

comment:2 Changed 5 years ago by Brian Riley

Owner: changed from nobody to Brian Riley
Status: newassigned

Changed 5 years ago by Brian Riley

comment:3 Changed 5 years ago by Brian Riley

Has patch: set

Changed 5 years ago by Brian Riley

Patch to add --database option to both createsuperuser and change password management commands

comment:4 Changed 5 years ago by Preston Holmes

did you note that I changed the summary - it would seem beneficial to fix this for both of the auth management commands - including changepassword

However this patch is still good - would you be willing to expand?

comment:5 Changed 5 years ago by Brian Riley

I did notice the summary change. The second patch I uploaded covers both createsuperuser and changepassword. The first patch can be ignored.

comment:6 Changed 5 years ago by Jannis Leidel

Triage Stage: AcceptedReady for checkin

comment:7 Changed 5 years ago by Chris Beaven

Resolution: fixed
Status: assignedclosed

In [17665]:

Fixes #17327 -- Add --database option to createsuperuser and change password management commands

Changed 5 years ago by Brian Riley

Moves multi DB tests for createsuperuser to regressiontests

comment:8 Changed 5 years ago by Brian Riley

Resolution: fixed
Status: closedreopened

Seems like most multi DB management commands are in regressiontests, so I moved the createsuperuser tests there. This will ensure that they aren't run when you run the tests on your Django project.

comment:9 Changed 5 years ago by Claude Paroz

Severity: NormalRelease blocker

comment:10 Changed 5 years ago by Ramiro Morales

Resolution: fixed
Status: reopenedclosed

In [17676]:

Fixed #17327 (again) -- Moved createsuperuser tests added in r17665.

In their new location they won't cause multi-db-related errors when
users run contrib.auh tests together with their application tests.

Thanks brianriley for the patch.

Note: See TracTickets for help on using tickets.
Back to Top