When I try to submit this form, it throws me an error saying ColumnFormFormSet objects has no attribute 'save'
from django import forms
from .models import Column
class ColumnForm(forms.ModelForm):
class Meta:
model = Column
fields = ['name', 'selec_type']
views.py:
From .forms import ColumnForm
From django.forms import formset_factory
def design(request):
ColumnFormSet = formset_factory(ColumnForm, extra=30)
formset = ColumnFormSet
if request.method == 'POST':
formset = ColumnFormSet(request.POST)
if formset.is_valid():
formset.save()
return redirect('Home')
else:
formset = ColumnFormSet()
return render (request, 'design.html', {'formset':formset})
template.design.html:
<form method='post'>
{% csrf_token %}
{{ formset.management_form}}
{% for form in formset %}
{{Form.as_p}}
{% endfor %}
<button type='submit'>Save<button/>
<form/>