可能重复:
Jquery validation - checking email and username availability from server-side Django
我想使用Jquery验证插件远程检查用户名和电子邮件可用性。但我得到了403 Forbidden - CSRF验证失败了。我不知道在哪里为Jquery Post Request使用Django csrf模板标签。
views.py:
def email_check(request):
response_str="false"
if request.is_ajax():
e = request.POST.get("email_address")
try:
obj = User.objects.get(email=e)
except DoesNotExist:
response_str="true"
return HttpResponse(response_str)
urls.py:
url(r'^signup/email/check/$', 'registration.views.email_check')
signup.html:https://gist.github.com/2253002
有人可以帮助我吗?
谢谢!