Django: CSRF check failed

I am trying to send a non-ssl-related page to an ssl-wrapped page, but I am getting this error.

CSRF verification failed. Request aborted.

Reason given for failure:
    Referer checking failed - http://<domain>/ does not match https://<domain>/.

That is, I am trying to send the username / password page to the login method.

How can I do this without getting this error?

Thanks eric

+3
source share
1 answer

If you think it's safe, here's how to specifically exempt the normal view from CSRF validation .

However , I assume that you are talking about submissions contrib.auth, then you may have to write your own version and apply a decorator @csrf_exemptinstead of this (i.e. copy, paste, change the decorator according to the method - this is not as painful as it seems) .

: CSRF, django.contrib.* CSRF. - /fork contrib; - - CSRF...

+3

Source: https://habr.com/ru/post/1772671/


All Articles