我正在尝试在 django 中保存一个表单集。为此,我有我的模型和自定义表格。然后我以这种方式创建我的表单集:
QuoteFormSet = formset_factory(QuoteForm, extra=2)
formset = QuoteFormset(request.POST)
但是当我做 formset.save() 我得到AttributeError: 'QuoteFormFormSet' object has no attribute 'save'
我的模型:
class Quote(models.Model):
country = models.CharField(max_length=2,)
street = models.CharField(max_length=100,)
我的表格:
class QuoteForm(forms.ModelForm):
class Meta:
model = Quote
country = forms.ChoiceField(choices=COUNTRIES, required=False)
street = forms.CharField(max_length=100, required=False)