class Member(models.Model):
dob = models.DateField('dob')
形式
class MemberForm(ModelForm):
dob = forms.DateField(required=False, input_formats='%Y-%m-%d')
class Meta:
model = Member
exclude = ('profile',)
一些視圖代碼
if request.method == 'POST': # If the form has been submitted...
signup_form = SignupForm(request.POST) # A form bound to the POST data
# Create a formset from the submitted data
member_formset = MemberFormSet(request.POST, request.FILES)
# import pdb; pdb.set_trace()
if signup_form.is_valid() and member_formset.is_valid():
print 'in valid'
signup = signup_form.save(request.POST)
for form in member_formset.forms:
member = form.save(commit=False)
member.profile = signup
# import pdb; pdb.set_trace()
# print member.objects.all()
member.save()
return redirect("/main") # Redirect to a 'success' page
當m提交表單來的錯誤信息是
Enter a valid date.
我應該如何解決此驗證問題。