Changes between Version 7 and Version 8 of Ticket #25304


Ignore:
Timestamp:
Nov 12, 2015, 5:27:47 PM (8 years ago)
Author:
Mounir
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #25304 – Description

    v7 v8  
    1 https://github.com/django/django/pull/5643
     1When creating a new project, you can sometimes forget to run `manage.py migrate` before creating the initial superuser (especially if you don't execute `runserver` before, which display a warning about migrations not applied). The resulting error make sense, it can't access to auth_user, since it does not exist yet:
     2               
     3               
     4                {{{
     5                $ django-admin.py startproject sample
     6                $ cd sample/ && python manage.py createsuperuser
     7                Traceback (most recent call last):
     8                  File "manage.py", line 10, in <module>
     9                    execute_from_command_line(sys.argv)
     10                [...]
     11                  File "/vagrant/django/django/contrib/auth/management/commands/createsuperuser.py", line 85, in handle
     12                    default_username = get_default_username()
     13                  File "/vagrant/django/django/contrib/auth/management/__init__.py", line 189, in get_default_username
     14                    auth_app.User._default_manager.get(username=default_username)
     15                [...]
     16                  File "/vagrant/django/django/db/backends/sqlite3/base.py", line 323, in execute
     17                    return Database.Cursor.execute(self, query, params)
     18                django.db.utils.OperationalError: no such table: auth_user
     19                }}}
     20               
     21                ... but with a little try/except, it could be nicer and give a more meaningful information:
     22               
     23                {{{
     24                $ python manage.py createsuperuser
     25                CommandError: You must execute `manage.py migrate` once before creating a super user
     26                }}}
     27               
     28                I have a patch ready (as I said, it just a try/except, see attachment) but, if accepted, it would need unit tests to be complete.
Back to Top