Code

Opened 6 years ago

Closed 6 years ago

Last modified 3 years ago

#7518 closed (duplicate)

django-admin.py syncdb cannot createsuperuser

Reported by: Karen Tracey <kmtracey@…> Owned by: nobody
Component: Core (Management commands) Version: master
Severity: Keywords:
Cc: dane.springmeyer@… Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

Problem reported on django-users: http://groups.google.com/group/django-users/browse_thread/thread/1426b66cb9cf0155

If you try to use 'django-admin.py syncdb' instead of 'python manage.py syncdb' to initialize a new database and create a superuser, the command fails like so:

You just installed Django's auth system, which means you don't have any superusers defined.
Would you like to create one now? (yes/no): yes
Error: Unknown command: 'createsuperuser'

django-admin.py calls django.core.management.execute_from_command_line()

while

manage.py calls django.core.management.execute_manager(settings)

The first creates a ManagementUtility and calls execute() on it while the 2nd creates a ProjectManagementUtility and calls execute() on it. The key difference between these two for this problem looks to be that the first's __init__ sets self.user_commands to False while the 2nd sets the same value to True. This value is passed as load_user_commands to get_commands and as a result the 1st (django-admin.py) does not load commands associated with all the apps in settings.INSTALLED_APPS. Therefore the auth's createsuperuser command is not found when the auth code runs its registered post_syncdb create_superuser function.

That's why it breaks. Not sure how to fix it since I don't really understand the distinction between ManagementUtility and ProjectManagementUtility and why that user_commands var is different for the two.

Attachments (0)

Change History (7)

comment:1 Changed 6 years ago by anonymous

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

#5943 can fix it.

comment:2 Changed 6 years ago by Karen Tracey <kmtracey@…>

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

Looks like #5943 will be going in, and should fix this.

comment:3 Changed 6 years ago by anonymous

I frequently use django-admin.py so here's a call out that fixing this would be really useful.

comment:4 Changed 6 years ago by anonymous

  • Cc dane.springmeyer@… added

comment:5 Changed 6 years ago by Karen Tracey <kmtracey@…>

#5943 is the one you really want to follow, this one has been closed in favor of that one.

comment:6 Changed 6 years ago by Alex Yu <stinky9@…>

This is how I fixed the problem temporary...

cd django/core/management/commands
ln -s ../../../contrib/auth/management/commands/createsuperuser.py .

comment:7 Changed 3 years ago by jacob

  • milestone 1.0 deleted

Milestone 1.0 deleted

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.