Django 4

发布于 2025-01-22 13:39:09 字数 230 浏览 3 评论 0 原文

似乎无法在我的制作中登录Django管理URL,但在我的本地上可以正常工作。对于上下文,目前我的网站没有SSL。调试也设置为错误。

这是在Django 4升级之前(以前在Django 3.08上使用)

mysite.com/admin 继续重定向到 mysite> mysite.com/admin/login/?next=/admin/ 有500个错误。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

追星践月 2025-01-29 13:39:09

将您的原点(域)添加到 csrf_trusted_origins settings.py文件中的变量。

CSRF_TRUSTED_ORIGINS = [
    'http://my.domain.com:8000'
]

参见

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

云醉月微眠 2025-01-29 13:39:09

已解决的

在浏览我的Django服务器日志后,事实证明是一个丢失的包装,称为 tzdata 。我将时区设置为UTC,因此在访问管理面板时会导致错误。

我的设置

TIME_ZONE = 'UTC'

USE_I18N = True

USE_L10N = True

USE_TZ = True

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!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文