我复制了完整的示例代码:[customizing admin user] [1](django文档的一部分),但是当我运行它时,django不会出错,但是当我添加一个用户,django会出现以下错误。 我没有改变这个例子的任何代码,并设置后续文件。 跟进链接例如: https://docs.djangoproject.com/en/1.8/topics/auth/customizing/#a-full-example来自Django文档的示例代码的错误
错误:
IntegrityError at /admin/app01/myuser/add/
NOT NULL constraint failed: app01_myuser.last_login
Request Method: POST
Request URL: http://127.0.0.1:8000/admin/app01/myuser/add/
Django Version: 1.8.5
Exception Type: IntegrityError
Exception Value:
NOT NULL constraint failed: app01_myuser.last_login
Exception Location: /Library/Python/2.7/site-packages/django/db/backends/sqlite3/base.py in execute, line 318
你能描述一下你的目标吗? ?还有,您是否更改了该代码? –
需要更多信息来解决此问题。确保你的数据库是最新的(做你的迁移)从1.7 - > 1.8 last_login字段的限制已经改变,尽管这可能不会影响你的应用程序,我不知道!并确保您从django.contrib.auth.models中导入用户。 –
我已经尝试使用新项目使用相同的代码从django文件,django(1.8)正常运行,但是当用户保存在管理员,错误会出来, – scott