让Django的@login_required装饰器工作还需要做些什么?

  发布于 2023-02-11 20:08

我正在尝试使用Django的帐户系统,包括@login_required装饰器.我的settings.py文件包含django.contrib.auth,我已经完成了syncdb.

Page not found (404)
Request Method: GET
Request URL:    http://localhost:8000/accounts/login/?next=/
Using the URLconf defined in dashboard.urls, Django tried these URL patterns, in this order:
^$ [name='home']
The current URL, accounts/login/, didn't match any of these.
You're seeing this error because you have DEBUG = True in your Django settings file. Change that to False, and Django will display a standard 404 page.

在尝试@ login_required-decorate我的主视图后,我看到了上面的内容.

它似乎很窒息,因为它被重定向到accounts/login /,我还没有在urls.py中准备好.

我可以添加到urls.py或其他地方,以便login_required装饰器将执行其通常的行为?

谢谢,

撰写答案
今天,你开发时遇到什么问题呢?
立即提问
热门标签
PHP1.CN | 中国最专业的PHP中文社区 | PNG素材下载 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有