Django inline form error

I am trying to add an inline set of forms to a form. Here is the minimum code to reproduce the error:

models.py

class Festival(Model): desc = TextField(max_length=1000) class FestivalAddress(Model): festival = ForeignKey(Festival, related_name="addresses") name = CharField(max_length="50") 

urls.py

 urlpatterns = patterns('', url('^add/$', FestivalCreateView.as_view(), name='festival_add'), ) 

views.py

 class FestivalCreateView(CreateView): model = Festival form_class = FestivalForm #Add FestivalAddressFormset to context here 

forms.py

 class FestivalAddressForm(ModelForm): class Meta: model = FestivalAddress class FestivalForm(ModelForm): class Meta: model = Festival FestivalAddressFormSet = inlineformset_factory(FestivalForm, FestivalAddress, form=FestivalAddressForm, extra=2) 

This raises AttributeError: the ModelFormOptions object does not have the attribute 'get_parent_list'. I'm a bit of a dead end since I am executing the solution given here in SO format .

Change I removed the use of the form set in FestivalCreateView because an error occurs with or without it.

+1
django django-forms inline-formset
Jun 25 2018-12-12T00:
source share
2 answers

Looks like my inlineformset_factory call was wrong. According to docs , the first argument should be a model, not a form.

+4
Jun 25 '12 at 23:55
source share

Must be: FestivalAddressFormSet = inlineformset_factory(Festival, FestivalAddress, form=FestivalAddressForm, extra=2)

0
Nov 27 '12 at 10:37
source share



All Articles