#25573 closed Cleanup/optimization (duplicate)
Add simple way to use SplitDateTimeField on ModelForms
| Reported by: | David Seddon | Owned by: | nobody |
|---|---|---|---|
| Component: | Forms | Version: | 1.9a1 |
| Severity: | Normal | Keywords: | |
| Cc: | Triage Stage: | Unreviewed | |
| Has patch: | no | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description
If you specify a SplitDateTimeWidget as the custom widget for a DateTimeField on a ModelForm, you receive this deprecation warning:
RemovedInDjango19Warning: Using SplitDateTimeWidget with DateTimeField is deprecated. Use SplitDateTimeField instead.
My understanding is that the only way to do this for a ModelForm based on a model with a DateTimeField, is to subclass models.DateTimeField like this: https://gist.github.com/nacady/8dd5cab2f749d1589f1e.
Perhaps we should provide a simpler way of using the SplitDateTimeField with ModelForms?
Note:
See TracTickets
for help on using tickets.
The
ModelForm.Meta.field_classesfeature added in Django 1.9 should allow this (#24295).