Re: [Django] #25304: Trying to create a super user before first migrate raise a database error

2015-08-25 Thread Django
#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
-+-

Comment (by mlorant):

 I agree with you, a developer should understand that a missing table on a
 Django default command means the database has not been created yet.
 However, I sometimes answer to question even more... easy *cough*... (like
 "Why my page is not working and throw `name 'url' is not defined` in
 urls.py").

 After some thoughts, the idea to raise the exception again with a hint
 seems more friendly for both usages (new Django users and skilled one),
 but it is not urgent at all. Also, it needs to establish a list of
 commands to improve...

--
Ticket URL: 
Django 
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 django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/065.35a0393721d080a0853a82d3917c8dd1%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #25304: Trying to create a super user before first migrate raise a database error

2015-08-24 Thread Django
#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
-+-

Comment (by timgraham):

 I don't see much advantage to this. In my opinion, a developer should be
 able to understand what the lack of a database table means. There are
 other management commands that access the database -- do they all need to
 be adjusted too?

--
Ticket URL: 
Django 
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 django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/065.d0fb4af526ce3727246bc828b25e3b87%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #25304: Trying to create a super user before first migrate raise a database error

2015-08-23 Thread Django
#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: 
Django 
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 django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
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.


Re: [Django] #25304: Trying to create a super user before first migrate raise a database error

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

 * Attachment "try-except-createsuperuser.diff" added.


--
Ticket URL: 
Django 
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 django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/065.bf705b394fa639cab065bba693265531%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


[Django] #25304: Trying to create a super user before first migrate raise a database error

2015-08-23 Thread Django
#25304: Trying to create a super user before first migrate raise a database 
error
--+
 Reporter:  mlorant   |  Owner:  nobody
 Type:  Cleanup/optimization  | Status:  new
Component:  contrib.auth  |Version:  1.8
 Severity:  Normal|   Keywords:
 Triage Stage:  Unreviewed|  Has patch:  1
Easy pickings:  1 |  UI/UX:  0
--+
 When 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:


 {{{
 $ django-admin.py startproject sample
 $ cd sample/ && python manage.py createsuperuser
 Traceback (most recent call last):
   File "manage.py", line 10, in 
 execute_from_command_line(sys.argv)
 [...]
   File
 "/vagrant/django/django/contrib/auth/management/commands/createsuperuser.py",
 line 85, in handle
 default_username = get_default_username()
   File "/vagrant/django/django/contrib/auth/management/__init__.py", line
 189, in get_default_username
 auth_app.User._default_manager.get(username=default_username)
 [...]
   File "/vagrant/django/django/db/backends/sqlite3/base.py", line 323, in
 execute
 return Database.Cursor.execute(self, query, params)
 django.db.utils.OperationalError: no such table: auth_user
 }}}

 ... but with a little try/except, it could be nicer and give a more
 meaningful information:

 {{{
 $ python manage.py createsuperuser
 CommandError: You must execute `manage.py migrate` once before creating a
 super user
 }}}

 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.

--
Ticket URL: 
Django 
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 django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/050.cf6bfb2f9c4bf09c08e124acb9e22705%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.