【发布时间】:2021-10-23 04:22:04
【问题描述】:
我已将我的 Django 应用程序与 MongoDB 连接,注册/登录/注销都可以正常工作。但是当我使用 Django 默认密码重置电子邮件时,它会引发数据库错误。
我累了什么:
- sqlite3 - 注册/登录/注销(工作)
- MongoDB - 注册/登录/注销(工作中)
- sqlite3 - 密码重置电子邮件(工作)
- MongoDB - 密码重置电子邮件(不工作)
我能够登陆 Django 密码重置页面,但是当我点击确认时,它会在浏览器上返回错误
DatabaseError at /pw_reset/
No exception message supplied
Request Method: POST
Request URL: http://localhost:8000/pw_reset/
Django Version: 3.2.6
Exception Type: DatabaseError
Exception Location:
C:...venv\lib\site-packages\djongo\cursor.py, line 59, in execute
The above exception ( Keyword: None Sub SQL: None FAILED SQL: ('SELECT "accounts_user"."id", "accounts_user"."password", "accounts_user"."last_login", "accounts_user"."is_superuser", "accounts_user"."username", "accounts_user"."first_name", "accounts_user"."last_name", "accounts_user"."email", "accounts_user"."is_staff", "accounts_user"."is_active", "accounts_user"."date_joined" FROM "accounts_user" WHERE ("accounts_user"."email" iLIKE %(0)s AND "accounts_user"."is_active")',) Params: (('test@test.com',),) Version: 1.3.6) was the direct cause of the following exception:
控制台日志:
Traceback (most recent call last):
File "C:...\lib\site-packages\django\template\base.py", line 850, in _resolve_lookup
(bit, current)) # missing attribute
django.template.base.VariableDoesNotExist: Failed lookup for key [name] in <URLResolver <URLPattern list> (admin:admin) 'admin/'>
网址路径:
path('pw_reset/', auth_views.PasswordResetView.as_view(), name="reset_password"),
我自己定义的视图(注册/登录/注销)都运行良好。但是内置的 PasswordRestView 不是。我已经尝试删除数据库,重新安装 djongo,但我的想法已经用完了...请帮助!
【问题讨论】:
-
您可以启用 Django 日志记录和读取查询。然后在 django dbshell 中测试查询
-
感谢@mrash,这似乎是键“名称”上的错误。不知道它指的是什么......我已经更新了这个问题。
-
我认为“用户名”是使用 AbstractUser 时的默认值,它正在工作,我可以看到在 MongoDB 中创建的 accounts_user。这就是为什么我不明白“名称”从何而来。
标签: django mongodb passwords djongo