django-user-accounts:没有这样的表:account_passwordhistory

问题描述 投票:0回答:1

有很多与django相关的帖子“没有这样的表”错误但没有来自django-user-accounts模块。我收到了这个错误

sqlite3.OperationalError:没有这样的表: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 makemigrationsNo changes detected。本文档中没有任何内容告诉我该怎么做:http://blog.pinaxproject.com/2016/11/22/how-configure-password-expiration-for-your-site/

谢谢

django authentication account
1个回答
0
投票

好吧,我的问题是我信任$ python manage.py makemigrations的输出,表明No changes detected。但是,当我运行$ python manage.py migrate时,它为account_passwordhistory和account_passwordexpire表应用了一个新的迁移:

Applying account.0003_passwordexpiry_passwordhistory... OK

表格在DB中。

设置我的密码在1秒内过期(python manage.py user_password_expiry my_user_name --expire 1)然而对网站功能没有任何影响,但这是一个不同的问题。

© www.soinside.com 2019 - 2024. All rights reserved.