Django中的错误:save()方法

时间:2011-05-22 22:23:51

标签: django django-models django-forms django-views

我不知道该怎么做。这个网页框架的新手请帮帮我 我收到这个错误:

unbound method save() must be called with DinkProfile instance as first argument (got nothing instead)

我的观点是:

dinkprofile = DinkProfile
dinkprofile.title = 'owner'
dinkprofile.user = request.user.id
dinkprofile.save()

型号名称:

class DinkProfile(models.Model):
    user = models.OneToOneField(auth.models.User)
    title = models.CharField(max_length=75)

1 个答案:

答案 0 :(得分:15)

您在这里缺少括号:

dinkprofile = DinkProfile

应该是:

dinkprofile = DinkProfile()