I have just created a new Django project and am getting a csrf verification error (403) when trying to log into django admin.
The setup steps I have taken are:
pip3 install django- django 4.0.1 is installed.
django-admin startproject myprojectname- myprojectname is successfully created.
python3 manage.py runserver- Server starts and django verification page is rendered.
python3 manage.py migrate- Migrations are applied ok
python3 manage.py createsuperuser- superuser is created successfully.
python3 manage.py runserverand append ‘/admin/’ to url - Django admin login page is rendered ok
- Enter superuser name and password to log in - csrf verification failed, 403 error
Steps taken to resolve the issue are:
- I have checked in the dev tools for the csrf token and it is applied via a hidden field in the login form as expected.
- I have cleared the session cookies and have applied a hard refresh of the page and retried to login but the error remains.
- I have opened the project in another browser but the error remains.
- I have opened a previous django project (uses django v3.1.2) and set a new superuser and logged in without any errors.
I am at a loss as to what further steps I can take to resolve this issue so any help on this matter is gratefully accepted.