当我syncdb我的数据库时,我收到错误 module'对象没有属性'OneToOnefield'
models.py的代码如下:
from django.db import models
from django.contrib.auth.models import User
from django.db.models.signals import post_save
class Drinker(models.Model):
user =models.OneToOnefield(User)
birthday =models.Datefield()
name =models.Charfield(max_length=100)
#create our user object to attach to our drinker object
def create_drinker_user_callback(sender, instance, **kwargs):
drinker.new=Drinker.objects.get_or_create(user=instance)
post_save.connect(create_drinker_user_callback, User)
答案 0 :(得分:3)
它应该是models.OneToOneField
,即具有大写字母'F'的字段。这也是您的其他字段定义的问题。