Django CSRF Problem

After upgrade to django 1.2.1, I encountered csrf porblems. I did these things to fix it:

modify settings.py, add

try:
    from django.middleware import csrf

    MIDDLEWARE_CLASSES += (
        'django.middleware.csrf.CsrfViewMiddleware',
        'django.middleware.csrf.CsrfResponseMiddleware',
        )
except:
    pass

below

MIDDLEWARE_CLASSES = (
    ......
)

add {% csrf_token %} in templates/admin/login.html ( Guess you must have override the login.html based on the old version ). The template tag csrf_token is default tag, you don’t need to load any extra tag libraries.

Don’t forget to restart your server.

This entry was posted in Django and tagged , . Bookmark the permalink.


2 Responses to Django CSRF Problem

  1. Maya Pousson says:

    This site seems to recieve a large ammount of visitors. How do you get traffic to it? It offers a nice individual twist on things. I guess having something useful or substantial to give info on is the most important thing.

  2. Thanks. Good job! Write more. It seems like I become regular visitor

Leave a Reply

Your email address will not be published. Required fields are marked *

*


*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>