I have a form on my page where the user needs to enter a date. I also have a DatePicker widget associated with this field in the form.
This is the field in my model:
date = models.DateField(default=timezone.now,
help_text=f'eg. {str(timezone.now().date())}',
validators=[MinValueValidator(timezone.now().date()),
MaxValueValidator((timezone.now() + timedelta(days=365)).date())
])
This is the field within my form:
date = forms.DateField(
widget=forms.DateInput(format="%d/%m/%Y",
attrs={'type': 'date',
'min': str(timezone.now().date()),
'max': str((timezone.now() + timedelta(days=365)).date())}),
help_text='Select a date',
input_formats=["%d/%m/%Y"],
validators=[validate_future_date],
)
This is how the HTML is being rendered when I access the page:
<div id="div_id_date" class="form-group">
<label for="id_date" class=" requiredField">
Date
<span class="asteriskField">*</span>
</label>
<div>
<input type="date" name="date" min="2024-03-24" max="2025-03-24" class="dateinput form-control" required="" id="id_date">
<small id="hint_id_date" class="form-text text-muted">Select a date</small>
</div>
</div>
I want to change the date input format to dd/mm/yyyy, but no matter what I try it always remains the same ( mm/dd/yyyy ). Please help