You can use modelform.
in your form.py you can do something like this
# setup date picker start
class DateInput(forms.DateInput):
input_type = 'date'
class Formname(forms.ModelForm):
class Meta:
model= yourmodel
fields = ('datefield')
widgets ={'datefield': DateInput() }
On Fri, Oct 8, 2021 at 11:01 AM Anil Felipe Duggirala <
[email protected]> wrote:
> 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 [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/c101be88-2409-4a12-b97b-1af7aa30048c%40www.fastmail.com
> .
>
--
--
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 [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-users/CAPCf-y5-jm1Q0SL0-HpCs%3DSyfFYDHqx_BBxBDs%3DGxjDY9gPJ5Q%40mail.gmail.com.