Hi!
Thanks for looking at this. For a few projects over the past 5 years, I’ve used native <input type=date> and friends, with custom widget subclasses. I think we’re ready to provide support in Django, but I’m not 100% sure on the plan to only provide a global setting that switches all forms over. Global switches are great for opting-in on new projects, but they’re not a useful tool for migrating existing codebases, where one often needs per-field control.
Additionally, BaseTemporalField (the base for DateField and friends), currently validates against locale-based formats, while <input type=date> and co. only send ISO8601 values. Your proposal has these keep working, but I think it would be best to avoid having unused parsing logic.
I think a gentler, more targeted plan would be better. The first release could do something like:
- Add
NativeDateInput,NativeTimeInput, andNativeDateTimeInputwidget classes (names to be bikeshedded). - Add
NativeDateFieldetc. that use these widgets by default. - Move the admin to use them, rather than its custom widgets, with a per-
ModelAdmin(?) option to switch back. (We can be more aggressive with the admin, as it’s a UI that we fully control.) - Document how to use
ModelFormOptions.formfield_callbackto switch your forms to use the native fields.
We could also consider a global switch that changes the defaults for forms to native fields, but given there would be a snippet to copy for your base field class, that could wait for a later release, when any rough edges have been tested.
What do you think?