'Can't login into admin URL on production with Django 4
Can't seem to login into Django admin URL on my production but it works fine on my local. For context, currently my site does not have SSL. Debug is set to False as well.
This was working prior to Django 4 upgrade (was previously on Django 3.08)
mysite.com/admin keeps redirecting to mysite.com/admin/login/?next=/admin/ with a 500 error.
Solution 1:[1]
SOLVED
After going through my Django server logs it turned out being a missing packaged called tzdata. I had my timezone set to UTC so it was causing an error when accessing the admin panel.
My settings.py regarding timzones
TIME_ZONE = 'UTC'
USE_I18N = True
USE_L10N = True
USE_TZ = True
Thanks everyone for their thoughts!
Solution 2:[2]
Add your origin (domain) to the CSRF_TRUSTED_ORIGINS variable in the settings.py file.
CSRF_TRUSTED_ORIGINS = [
'http://my.domain.com:8000'
]
See https://docs.djangoproject.com/en/4.0/releases/4.0/#csrf-trusted-origins-changes-4-0
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | 6ixpaths |
| Solution 2 |
