Search code examples
djangopython-3.xdjango-admincsrf-token

CSRF token missing or incorrect - Django 2.2


I try to create an admin user in my application, but even I do not include any code, it gives the error 'CSRF token missing or incorrect'. I can't find what to do. Can anyone solve this problem?

I tried all the suggestions from my friends, and Django documentation, but none of them could solve it.

Actually, there is no need to paste my code, because as I mentioned before even without any HTML templates it is not possible to create an admin user.

enter image description here


Solution

  • Admin login normally does require a CSRF token, but that's usually all taken care for you. Despite being as you have faced the following problem, this could be generating from your browser extensions.

    • Check your browser's cookies to see if there is a CSRF token present
    • Try clearing all the cookies, disabling the browser extensions and refreshing

    OR just try from another browser which does not have any extensions and cookies are present.