【发布时间】:2011-12-11 21:30:44
【问题描述】:
我对 django formset 有疑问。我想验证表单集中的一个字段。我关注了这些链接 Django Passing Custom Form Parameters to Formset
并且能够创建表单。
但是如何将我的数据发布到表单集。
这是我的表格
class BookingDetailsForm(forms.Form):
age = forms.IntegerField()
def __init__(self, trip, *args, **kwargs):
super(BookingDetailsForm, self).__init__(*args, **kwargs)
age = self.fields["age"]
trip = trip
print "This prints when formset is created"
def clean_age(self):
// want some checking here
#raise ValidationError('Error msg')
return self.cleaned_data['age']
我的看法是
formset = formset_factory(BookingDetailsForm, extra=number_of_peoples)
formset.form = staticmethod(curry(BookingDetailsForm, trip))
// above two line is working perfectly
那么我该如何发布我的表单集呢??
formset = formset_factory(BookingDetailsForm, trip, request.POST)// not working
发布后我想用干净的方法检查年龄字段。
【问题讨论】:
标签: django django-forms django-views