2

当我同步我的数据库时,我收到模块'对象的错误没有属性'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)
4

1 回答 1

4

它应该是models.OneToOneField带有大写“F”的字段。这也是您的其他字段定义的问题。

于 2012-08-30T05:59:07.723 回答