#23365: makemigrations with a new not nullable DateTimeField leads to
RuntimeWarning
---------------------------------+-----------------------
     Reporter:  rasca            |      Owner:  nobody
         Type:  Bug              |     Status:  new
    Component:  Migrations       |    Version:  1.7-rc-3
     Severity:  Release blocker  |   Keywords:  migration
 Triage Stage:  Unreviewed       |  Has patch:  0
Easy pickings:  0                |      UI/UX:  0
---------------------------------+-----------------------
 When adding a new not nullable DateTimeField to a model it prompts you to
 select a default:

 {{{
 You are trying to add a non-nullable field '...' to user without a
 default;
 we can't do that (the database needs something to populate existing rows).
 Please select a fix:
  1) Provide a one-off default now (will be set on all existing rows)
  2) Quit, and let me add a default in models.py
 Select an option: 1
 Please enter the default value now, as valid Python
 The datetime module is available, so you can do e.g. datetime.date.today()
 }}}

 If you have `USE_TZ = True` then using `datetime.date.today()` and
 executing the migration results in:

 {{{
 RuntimeWarning: DateTimeField ... received a naive datetime (...) while
 time zone support is active.
 }}}

 I think we should be using:

 {{{
 >>> django.utils.timezone.now
 Invalid input: name 'django' is not defined
 }}}

 but it's not possible. I think we should add the django namespace to the
 prompt and use a different message in case `USE_TZ = True`

--
Ticket URL: <https://code.djangoproject.com/ticket/23365>
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/048.6b064482231715fb7960293bace4ab1c%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to