Code

Opened 2 years ago

Closed 2 years ago

#17327 closed New feature (fixed)

contrib.auth management commands ignores --database option

Reported by: skam <massimo.scamarcia@…> Owned by: brianriley
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 brianriley 2 years ago.
auth-management-commands-database-option.diff (11.6 KB) - added by brianriley 2 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 brianriley 2 years ago.
Moves multi DB tests for createsuperuser to regressiontests

Download all attachments as: .zip

Change History (13)

comment:1 Changed 2 years ago by ptone

  • Component changed from Core (Management commands) to contrib.auth
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Summary changed from createsuperuser management command ignores --database option to contrib.auth management commands ignores --database option
  • Triage Stage changed from Unreviewed to Accepted
  • Type changed from Uncategorized to New feature

comment:2 Changed 2 years ago by brianriley

  • Owner changed from nobody to brianriley
  • Status changed from new to assigned

Changed 2 years ago by brianriley

comment:3 Changed 2 years ago by brianriley

  • Has patch set

Changed 2 years ago by brianriley

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

comment:4 Changed 2 years ago by ptone

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 2 years ago by brianriley

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 2 years ago by jezdez

  • Triage Stage changed from Accepted to Ready for checkin

comment:7 Changed 2 years ago by SmileyChris

  • Resolution set to fixed
  • Status changed from assigned to closed

In [17665]:

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

Changed 2 years ago by brianriley

Moves multi DB tests for createsuperuser to regressiontests

comment:8 Changed 2 years ago by brianriley

  • Resolution fixed deleted
  • Status changed from closed to reopened

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 2 years ago by claudep

  • Severity changed from Normal to Release blocker

comment:10 Changed 2 years ago by ramiro

  • Resolution set to fixed
  • Status changed from reopened to closed

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.

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.