Opened 16 years ago

Closed 16 years ago

Last modified 13 years ago

#7518 closed (duplicate)

django-admin.py syncdb cannot createsuperuser

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

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.

Change History (7)

comment:1 by anonymous, 16 years ago

#5943 can fix it.

comment:2 by Karen Tracey <kmtracey@…>, 16 years ago

Resolution: duplicate
Status: newclosed

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

comment:3 by anonymous, 16 years ago

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

comment:4 by anonymous, 16 years ago

Cc: dane.springmeyer@… added

comment:5 by Karen Tracey <kmtracey@…>, 16 years ago

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

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

This is how I fixed the problem temporary...

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

comment:7 by Jacob, 13 years ago

milestone: 1.0

Milestone 1.0 deleted

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