我複製了完整的示例代碼:[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