Django 完全粘贴官方文档代码出错,搜索 Stackoverflow,有相似的,但是没有相同的问题,有谁帮看看?

2016-04-14 22:38:45 +08:00
 scott123

官方文档 : <https://docs.djangoproject.com/en/1.8/topics/auth/customizing/#a-full-example /> 直接复制链接里的例子代码,未做修改。 在 setting 注册了 user

error:

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
2695 次点击
所在节点    Python
3 条回复
virusdefender
2016-04-14 23:29:52 +08:00
last_login 那个不能为空,但是我看了下我 Django 1.9 的 AbstractBaseUser, last_login 是 null=True 的啊。

你是哪个函数里面报错的啊,实在不行手动赋值 last_login
facert
2016-04-15 10:54:12 +08:00
last_login field changed in django 1.8. Just run the migrations

python manage.py migrate
scott123
2016-04-19 21:18:07 +08:00
在 Admin web 页面里手动注册用户的时候,会爆错,运行时不回爆错,我的 AbstractBaseUser, last_login 也是 null=True ,试了 makemigrations ,migrate,syncdb,都不行,

Request Method: POST
Request URL: http://127.0.0.1:8000/admin/app01/myuser/add/
Django Version: 1.9.4
Exception Type: IntegrityError
Exception Value:
NOT NULL constraint failed: app01_myuser.last_login
Exception Location: /Users/dushibing/My_blog_env/lib/python2.7/site- packages/django/db/backends/sqlite3/base.py in execute, line 323

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/271152

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX