Change field type in Django ModelFormset

In Django ModelForm, you can change the type of field widgets as follows:

class EntryForm(ModelForm):
    entity = forms.CharField()

    class Meta:
        model = Entry

I can easily create a model model from the same model as this:

EntryFormSet = modelformset_factory(Entry)

But is there a way to enable change of change of input field type when creating modelformset?

+5
source share
2 answers

EntryFormSet = modelformset_factory (Entry, form = EntryForm)

+13
source

modelformset_factoryaccepts a keyword argument formthat, I believe, will allow you to go through your form class and use it ...

+4
source

All Articles