(Django) Cannot assign “u'1'”: “StaffProfile.user” must be a “User” instance

前端 未结 2 383
情话喂你
情话喂你 2020-12-14 18:09

I have a model like below:

class StaffProfile(models.Model):
    user = models.ForeignKey(User)
    maas = models.FloatField()
    maas_gunu = models.CharFie         


        
2条回答
  •  别那么骄傲
    2020-12-14 19:06

    user needs to be an instance of the User model, not a unicode object (which is what you are passing it).

提交回复
热议问题