When I try to submit a form in my django project, I get an error saying, 
"CSRF token missing or incorrect," even though I put a "{% csrf_token %}" 
tag inside the form.

Here is signup.html:

<html>
<head>
<title>
Sign up
</title>
</head>
<body>
<form method="POST" action="/signup/">
 {% csrf_token %}
 Name: <input type="text" /><br />
 E-mail address: <input type="email" /><br />
 Password: <input type="password" /><br />
 <input type="submit" value="Submit" />
</form>
</body>
</html>

Here is a part of views.py:

def signup(request):
    if request.method == 'POST':
        user = User.new()
        user.name = request.POST["name"]
        user.email = request.POST["email"]
        user.password = request.POST["password"]
        return HttpResponse("User created")
    else:
        return render_to_response('micropost/signup.html')

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/3dj5GbXKavAJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to