#27304: Django 1.10 onwards broke previous behaviour for models.DateTimeField() 
in
Admin
-------------------------+-------------------------------------------------
     Reporter:  Kegan    |      Owner:  nobody
  Gan                    |
         Type:  Bug      |     Status:  new
    Component:           |    Version:  1.10
  contrib.admin          |   Keywords:  model admin datetime
     Severity:  Normal   |  formfield_overrides AdminDateWidget widget
 Triage Stage:           |  Has patch:  0
  Unreviewed             |
Easy pickings:  0        |      UI/UX:  0
-------------------------+-------------------------------------------------
 In Django 1.9 and prior, we can use a date widget in Admin for a
 `datetime` field. Specifically, we can override the default `datetime`
 widget in Admin using `AdminDateWidget`. In this way, user are only
 require to enter a ''date''. The ''time'' will be default 0h 0m 0s.

 From Django 1.10 onwards, this behaviour has break. Now, there is an error
 `Enter a list of values.` on save in Admin.

 Example code.

 Model:
 {{{
 class Highlight(models.Model):
     end_at = models.DateTimeField()

     def save(self, *args, **kwargs):
         # Add 23 hours, 59 minutes, 59 seconds to end_at so that it
 represent end of day.
         extratime = timedelta(hours=23, minutes=59, seconds=59)
         if self.end_at:
             self.end_at = self.end_at + extratime
         super(Highlight, self).save(*args, **kwargs)
 }}}

 Admin:
 {{{
 class HighlightAdmin(admin.ModelAdmin):
     formfield_overrides = {
         models.DateTimeField: {'widget': widgets.AdminDateWidget},
     }
 }}}

 Now there is no easy way to let user only input the ''date'' part of
 `datetime`field  in Admin.

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

Reply via email to