Django 会话立即过期

发布于 2024-11-28 12:55:16 字数 179 浏览 2 评论 0原文

我遇到了 Django 和 Django Auth 的问题。有时登录页面将不允许用户登录。当用户按下登录(在 /admin 登录表单或任何自定义登录表单上)时,页面就会刷新。进一步调试后,似乎它正在创建一个会话,然后使其过期(以某种方式)。有人在 Django Auth 中遇到过这种类型的行为吗?

谢谢,

科里

I'm experiencing an issue with Django and Django Auth. From time to time the login page will not allow users to login. When the user presses login (on the /admin login form OR any custom login form) the page simply refreshes. After debugging further it seems that it is creating a session and then expiring it (somehow). Has anyone experienced this type of behavior with Django Auth?

Thanks,

cory

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

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

发布评论

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

评论(1

金橙橙 2024-12-05 12:55:16

我没有遇到这个问题。

但是,您应该在 settings.py 文件中检查您的应用程序、中间件和上下文处理器规范。您需要确保以下各项都已到位(除了您的特定应用程序所需的其他内容之外):

MIDDLEWARE_CLASSES = (
    # ...
    'django.middleware.common.CommonMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    # ...
)

TEMPLATE_CONTEXT_PROCESSORS = (
    # ...
    "django.core.context_processors.auth",
    "django.core.context_processors.request",
    # ...
)

INSTALLED_APPS = (
    # ...
    'django.contrib.auth',
    'django.contrib.sessions',
    'django.contrib.sites',
    # ...
)

...确保一切顺利,看看您的问题是否仍然存在。祝你好运。

I haven't had this problem.

But so, you should check your apps, middleware, and context processor specifications in your settings.py file. You'll want to be sure the following are in place (in addition to whatever else you need for your specific app):

MIDDLEWARE_CLASSES = (
    # ...
    'django.middleware.common.CommonMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    # ...
)

TEMPLATE_CONTEXT_PROCESSORS = (
    # ...
    "django.core.context_processors.auth",
    "django.core.context_processors.request",
    # ...
)

INSTALLED_APPS = (
    # ...
    'django.contrib.auth',
    'django.contrib.sessions',
    'django.contrib.sites',
    # ...
)

... make sure that's all good to go and see if your problem persists. Good luck.

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