On Thu, Oct 7, 2021, at 5:50 PM, sum abiut wrote:
> 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() }

Thank you for the quick response Sum. I am still unsure about the usage of 
ModelForm, do I need to specify somewhere that the CreateView should use the 
ModelForm I define instead of the default form?
Where am I supposed to declare the 'class Formname...' ? (Is this supposed to 
be done in the models.py file or in the forms.py file?) 
Previously you meant the forms.py file right ? (not 'form.py')
The fields list is supposed to be in [] and not in () right?

Why doesn't the default form, that is automatically generated from the model 
when one uses the CreateView class based view , include the correct widgets?

thanks again,

-- 
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/051ad512-e66e-4a08-aece-57e1df6be309%40www.fastmail.com.

Reply via email to