Django CSRF Framework having many failures

后端 未结 4 565
逝去的感伤
逝去的感伤 2021-02-04 18:48

I\'m getting many failures from the CSRF Django middleware on my site (the version from SVN trunk.) The only errors I get are: CSRF failure: reason=CSRF token missing or incorr

4条回答
  •  深忆病人
    2021-02-04 19:28

    Also you should check the order of the MIDDLEWARE_CLASSES in your settings.py file. Should look something like this:

    MIDDLEWARE_CLASSES = (
        'django.middleware.common.CommonMiddleware',
        'django.contrib.sessions.middleware.SessionMiddleware',
        'django.middleware.csrf.CsrfViewMiddleware',
        'django.contrib.auth.middleware.AuthenticationMiddleware',
        'django.contrib.messages.middleware.MessageMiddleware',
        'django.middleware.locale.LocaleMiddleware',
    )
    

    LocaleMiddleware at the end. For me, the solution was the RequestContext instance and the ordering.

提交回复
热议问题