Code

Opened 2 years ago

Closed 2 years ago

#17898 closed Bug (fixed)

The database option is not honored when `createsuperuser` is called by `syncdb`

Reported by: charettes Owned by: nobody
Component: contrib.auth Version: 1.3
Severity: Release blocker Keywords: syncdb createsuperuser database multidb
Cc: Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: yes Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

When calling the syncdb command with a database kwarg

./manage.py syncdb --database my_specific_db

The post_sync_db signal is dispatched correctly but the django.contrib.auth.management.create_superuser receiver doesn't take the db kwarg into account when calling createsuperuser thus it attempts to create it on the default database. It should call the command on the database specified in syncdb.

I'm attaching a patch but I really don't know where I should add tests for this, I can't find where syncdb is tested. Is it??

Attachments (1)

syncdb-multidb-createsuperuser.diff (1021 bytes) - added by charettes 2 years ago.

Download all attachments as: .zip

Change History (4)

Changed 2 years ago by charettes

comment:1 Changed 2 years ago by julien

  • Needs documentation unset
  • Needs tests set
  • Patch needs improvement unset
  • Severity changed from Normal to Release blocker

I haven't verified the issue yet, but this could potentially be a bug in a new feature (added in [17665]), therefore marking as release blocker.

Last edited 2 years ago by julien (previous) (diff)

comment:2 Changed 2 years ago by charettes

I can confirm r17665 introduced the regression.

Everything worked just fine before this changeset since I was using a router to specify the User's db_for_(write|read). Now that using(database) is explicitly called in the createsuperuser command it's not asking the router anymore therefore triggering this issue.

comment:3 Changed 2 years ago by ubernostrum

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

In [17738]:

Fixed #17898: Ensure create_superuser honors the 'db' argument from post_sync_db. Thanks to charettes 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.