error_messages={"invalid": u"验证码错误"} 无效
来源:6-8 用户注册-2
一一倾
2017-08-02
我的代码:
class RegisterForm(forms.Form):
email = forms.EmailField(required=True)
password = forms.CharField(required=True, min_length=5)
captcha = CaptchaField(error_messages={"invalid": u"验证码错误"})
def post(self, request):
register_form = RegisterForm(request.POST)
if register_form.is_valid():
email = request.POST.get("email", "")
password = request.POST.get("password", "")
user_profile = UserProfile()
user_profile.username = email
user_profile.email = email
user_profile.password = make_password(password)
user_profile.save()
return render(request, "login.html", {})
else:
return render(request, 'register.html', {'register_form': register_form})
debug显示:<ul class="errorlist"><li>这个字段是必填项。</li></ul>
1回答
-
bobby
2017-08-03
captcha = CaptchaField(error_messages={"required": u"请输入验证码"}) 你这个错误是因为没有填写这个字段的错误 但是你的配置只是指明了如果invalid应该显示什么值
00
相似问题