添加UserProfile对象时的属性错误

时间:2016-01-10 12:31:18

标签: mysql django

我最近将Django 1.7.1迁移到了Django 1.9.1。如果我尝试将UserProfile添加到新用户(一对一映射),我会收到属性错误。

AttributeError at /admin/coffee/userprofile/add/
'bool' object has no attribute '_committed'
Request Method: POST
Request URL:    http://127.0.0.1:8000/admin/coffee/userprofile/add/
Django Version: 1.9.1
Exception Type: AttributeError
Exception Value:    
'bool' object has no attribute '_committed'
Exception Location: /tmp/idly/lib/python2.7/site-packages/django/db/models/fields/files.py in pre_save, line 309
Python Executable:  /tmp/idly/bin/python
Python Version: 2.7.10
Python Path:    
['/Users/nlokesh/idly',
 '/tmp/idly/lib/python27.zip',
 '/tmp/idly/lib/python2.7',
 '/tmp/idly/lib/python2.7/plat-darwin',
 '/tmp/idly/lib/python2.7/plat-mac',
 '/tmp/idly/lib/python2.7/plat-mac/lib-scriptpackages',
 '/tmp/idly/Extras/lib/python',
 '/tmp/idly/lib/python2.7/lib-tk',
 '/tmp/idly/lib/python2.7/lib-old',
 '/tmp/idly/lib/python2.7/lib-dynload',
 '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7',
 '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin',
 '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk',
 '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac',
 '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages',
 '/tmp/idly/lib/python2.7/site-packages',
 '/Library/Python/2.7/site-packages/pip-7.1.0-py2.7.egg',
 '/Library/Python/2.7/site-packages',
 '/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python',
 '/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC']

models.py中用户与UserProfile之间的关系:

user= models.OneToOneField(User, null=True)

0 个答案:

没有答案