Saturday, July 6, 2013

CSRF verification failed

Hello!
I am getting CSRF verification failed error, even after i added {% csrf_token %} tag in the html file.

Here's my html file:

{% extends "base.html" %}
{% block title %} User Registration {% endblock %}
{% block head %} User Registration {% endblock %}
{% block content %}
    <form method = "post" action = ".">
    {% csrf_token %}
        {{ form.as_p }}
        <input type ="submit" value="register" />
    </form>
{% endblock %}

and my views.py:

def register_page(request):
    if request.method == 'POST':
        form = RegisrationForm(request.POST)
        if form.is_valid():
            user = User.objects.create_user(
                username = form.cleaned_data['username'],
                password = form.cleaned_data['password1'],
                email = form.cleaned_data['email']
                )
            return HttpResponseRedirect('/')
        else:
            form = RegisrationForm()
            variables = RequestContext(request, {
                'form': form
                })
            return render_to_response('registration/register.html',
                variables)
    else:
        return render_to_response('registration/register.html')

Where am i doing wrong???

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate