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.
* needs_better_patch: => 0
* needs_tests: => 0
* needs_docs: => 0
Comment:
Can you [https://docs.djangoproject.com/en/dev/internals/contributing
/triaging-tickets/#bisecting-a-regression bisect] to find where the
behavior changed? Without looking into the details, I'm not immediately
convinced we should treat this as a bug and provide backwards-
compatibility for it, but we'll see.
--
Ticket URL: <https://code.djangoproject.com/ticket/27304#comment:1>
* status: new => closed
* resolution: => invalid
Comment:
Bisected to b9290b1d49538c1092b59c41e6046b11c25ecafb. To adapt your code,
you must add `'form_class': forms.DateField` to the override.
--
Ticket URL: <https://code.djangoproject.com/ticket/27304#comment:2>
Comment (by Kegan Gan):
Thanks Tim! It worked.
For reference, to override admin widget, use the following:
{{{
formfield_overrides = {
models.DateTimeField: {'form_class': forms.DateTimeField,
'widget': widgets.AdminDateWidget},
}
}}}
Also refer to #26449.
--
Ticket URL: <https://code.djangoproject.com/ticket/27304#comment:3>