I understand that in a built-in Django filter called date.
I want to modify the date format of a DateTimeInput, but I can’t figure it out without actually manually writing out the entire HTML. So currently I do something like this:
<input id="{{ field.id_for_label }}" type="text" name="{{ field.name }}" value="{{ field.value|date:"F j, Y, g:i a" }}"
class="round datetimepicker {% if field.errors %}error-input{% endif %}"
/>
Notice how I use value="{{ field.value|date:"F j, Y, g:i a" }}" (those double quotes actually work).
Is there an easier way to do this? Preferably I would like to keep it the same format as my other input fields:
{{ field|add_class:"round datetimepicker"|add_error_class:"error-input" }}
where add_class and add_error_class is from Django widget tweaks app.
I checked the docs.
the DateTimeInput widget
takes one optional argument as the format of its initial value.
Hope that helps