django-admin.py syncdb cannot createsuperuser
|Reported by:||Karen Tracey <kmtracey@…>||Owned by:||nobody|
|Component:||Core (Management commands)||Version:||master|
|Has patch:||no||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
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()
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 Changed 6 years ago by anonymous
- Needs documentation unset
- Needs tests unset
- Patch needs improvement unset
comment:2 Changed 6 years ago by Karen Tracey <kmtracey@…>
- Resolution set to duplicate
- Status changed from new to closed