DEV Community

Discussion on: Django inline formsets with Class-based views and crispy forms

Collapse
 
golimaarbhejeme profile image
AgnosticIndian!!!

There is something missing about the usage of the jquery plugin. I do not see the 'add' and remove' buttons added to the html at my end.

Collapse
 
marlonleite profile image
Marlon • Edited

The jquery add and remove buttons works only if there set a context['formset'] name. I do not know why. Maybe django 2 version or needs change the class Formset(LayoutObject)

So its works:

forms.py:

Fieldset(
'Add videos',
Formset('formset'),
),

views:

context['formset'] = PostVideoFormSet( self.request.POST, instance=self.object)

but if change this name to:

Fieldset(
'Add videos',
Formset('videos'),
),
and context['videos'] = PostVideoFormSet( self.request.POST, instance=self.object)

the buttons add and remove disappear