Answer to this query on stack overflow
<https://stackoverflow.com/questions/27321692/override-a-django-generic-class-based-view-widget>
Raw link:
https://stackoverflow.com/questions/27321692/override-a-django-generic-class-based-view-widget
Hope this helps,
A fellow django developer
On Friday, 8 October 2021 at 07:44:10 UTC+5:30 Anil Felipe Duggirala wrote:
> 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/e55edffa-b709-4ad6-88b7-1e9c83b7e33dn%40googlegroups.com.