Last updated November 08, 2025
Originally published on October 21, 2025
A modern Django HTML date input
As the purpose of Django's form widget for dates is strictly to validate your input as a well-formed date, you’ll often need to rely instead on the more refined user experience offered by the HTML5 date picker.
Doing so is actually quite straightforward. First, let’s inherit from the default DateInput to take advantage of all its freebies:
from django.forms.widgets import DateInput as DjangoDateInput
class DateInput(DjangoDateInput):
"""HTML5 date widget."""
Next, let's make the crucial change by setting the input type to the one we’re accustomed to seeing in HTML5:
from django.forms.widgets import DateInput as DjangoDateInput
class DateInput(DjangoDateInput):
"""HTML5 date widget."""
input_type = "date"
Find here a more comprehensive example, setting minimum and maximum thresholds for the selectable year.