1👍
✅
You need to be clearer about what you want to do. You mean you want to change the way the date is displayed? You don’t do that in the form at all, especially not in the __init__
. Displaying values is the job of the widget.
The DateTimeWidget already accepts a format
argument that controls the way the value is displayed. You can set this in the field declaration itself.
class MyModelForm(forms.ModelForm):
datetime = forms.DateTimeField(widget=forms.DateTimeInput(format="%B %d, %Y %I:%M%p"))
Source:stackexchange.com