#25304: Trying to create a super user before first migrate raise a database 
error
-------------------------------------+-------------------------------------
     Reporter:  mlorant              |                    Owner:  nobody
         Type:                       |                   Status:  new
  Cleanup/optimization               |
    Component:  contrib.auth         |                  Version:  1.8
     Severity:  Normal               |               Resolution:
     Keywords:                       |             Triage Stage:
                                     |  Unreviewed
    Has patch:  1                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  1
Easy pickings:  1                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Changes (by shaib):

 * needs_better_patch:   => 1
 * needs_tests:   => 0
 * needs_docs:   => 0


Comment:

 Hi,

 Thanks for filing this report and patch. I think the patch is not an
 improvement, though:

 * The claim that you must run "migrate" is not true, the table could be
 created in other ways;
 * Since the user model is swappable, many interesting things could be
 different from default;
 * I suspect other database backends will throw different errors here;
 * I suspect the sqlite backend will throw an `OperationalError` in
 different circumstances (e.g. the database file cannot be written to
 because of permissions or non-existing directory or device full or
 whatever)

 The error message, in general, could be made friendlier, but the source
 error must not be hidden. I think we could accept a similar modification
 where the `except:` clause catches `DatabaseError`, prints a hint along
 the lines of "Have you run initial migrations for this project?",  and re-
 raises the exception.

 For a test, I think you should try to temporarily swap out the user model;
 that should create the invalid code-vs-database state to trigger the
 exception.

--
Ticket URL: <https://code.djangoproject.com/ticket/25304#comment:1>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/065.c14ef26988b170844aad6e1bc37fe37c%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to