我已经阅读了http://www.b-list.org/weblog/2006/jun/06/django-tips-extending-user-model/但在使用 ForeignKey 迁移我的新数据库模式时仍然遇到问题对于产品列表中的用户
我的代码的简化版本是:
from django.contrib.auth.models import User
# other imports
class Product(models.Model):
author = models.ForeignKey(User)
# other product fields..
但是当我尝试迁移到 South 时,这可能是问题所在,因为我的用户数据库不是由 South 处理的(??原谅我的新手)我收到需要设置默认值的错误:
_mysql_exceptions.OperationalError: (1067, "Invalid default value for 'author_id'")
谁能解释我做错了什么?理想情况下,我不想要用户的默认值,或者至少为 null、false 或 0(但这似乎不起作用)..
非常感谢,
亚当