Thursday, October 7, 2021

DateTime widget in default CreateView form

hello,
I have tried to find an answer to this question online, with no clear response.
I have created a simple class based CreateView for a model that has a DateTime attribute.
Simply rendering the form using the {{ form.as_p }} tag in the template associated to the aforementioned view does not give me a DateTime widget in the form.

What is the easiest way or most standard way to achieve this?
I have read something about ModelForm, should I use that? Would that automatically give me a widget in the rendered HTML?

I would also like to know, how would I render that form using crispy forms?

Thanks very much for your help.



--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/c101be88-2409-4a12-b97b-1af7aa30048c%40www.fastmail.com.

No comments:

Post a Comment