【发布时间】:2019-03-27 16:53:44
【问题描述】:
有很多与 django 相关的帖子带有“没有这样的表”错误,但没有一个来自 django-user-accounts 模块。 我收到此错误
sqlite3.OperationalError: no such table: account_passwordhistory
,步骤如下:
已安装 django-user-accounts:
$ pip install django-user-accounts
Collecting django-user-accounts
Downloading https://files.pythonhosted.org/packages/0c/4f/40f76395324d98b7f8717aad7e08ad6f86ba2714eb956be6070e0402988c/django_user_accounts-2.0.3-py2.py3-none-any.whl (106kB)
100% |████████████████████████████████| 112kB 2.8MB/s
.
.
.
Installing collected packages: django-appconf, django-user-accounts
Successfully installed django-appconf-1.0.2 django-user-accounts-2.0.3
在 settings.py 中添加
INSTALLED_APPS = [ . . .
'django.contrib.sites',
'account' ]
SITE_ID = 1
MIDDLEWARE = [
.
.
.
'account.middleware.ExpiredPasswordMiddleware',
]
ACCOUNT_PASSWORD_USE_HISTORY = True
ACCOUNT_PASSWORD_EXPIRY = 60 # number of seconds
重新启动服务器并运行:$ python manage.py user_password_history
我明白了:
Traceback (most recent call last):
File "/Users/ipozdnya/miniconda3/lib/python3.5/site-packages/django/db/backends/utils.py", line 65, in execute return self.cursor.execute(sql, params)
File "/Users/someuser/miniconda3/lib/python3.5/site-packages/django/db/backends/sqlite3/base.py", line 328, in execute return Database.Cursor.execute(self, query, params)
sqlite3.OperationalError: no such table: account_passwordhistory
我意识到 account_passwordhistory 没有在安装或其他步骤时创建。 $ python manage.py makemigrations 声明 No changes detected。该文档中没有任何内容告诉我该怎么做:http://blog.pinaxproject.com/2016/11/22/how-configure-password-expiration-for-your-site/
谢谢
【问题讨论】:
标签: django authentication account