ForeignKey does not allow null values

前端 未结 4 554
遥遥无期
遥遥无期 2020-12-12 22:19

I am using the Django REST Framework 2.0.

Here is my model class:

class Mission(models.Model):
  assigned_to = models.ForeignKey(\'auth.User\',
                


        
4条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-12 22:34

    In my case, required=False wasn't enough. I needed allow_null in the serializer, per Django ForeignKey field required despite blank=True and null=True.

提交回复
热议问题