In my creation template, the date field is rendered as a CharField and does not allow to select a date, while I need this validation date.
My Model includes a DateField :
class Interview(models.Model):
date_planned = models.DateField(verbose_name="Planned Date", blank=True, null=True)
My View calls the ModelForm quite normally:
class InterviewCreateView(UserAccessMixin, CreateView):
permission_required = "interviews.add_interview"
model = Interview
form_class = InterviewForm
fields = ['date_planned', 'topics']
template_name = "interviews/interview_create_form.html"
success_url = reverse_lazy("interviews:interviews_list")
```
My Form just calls the Meta and includes a widget:
class InterviewForm(ModelForm): def init(self, *args, **kwargs): super().init(*args, **kwargs) self.fields['date_planned'].widget.attrs.update({'size': 40, 'type': 'date'})
class Meta:
model = Interview
fields=['topics', 'date_planned']```
Indeed the size of the input fields goes up to 40, however the date format is ignored by the system and lets my date_planned field being displayed as a CharField