Django REST Framework NOT NULL constraint failed
问题 when I try to create a new Post by posting the following JSON: { "text": "test", "location": 1 } I get the following error: NOT NULL constraint failed: grapevineapp_post.location_id models.py: class Location(models.Model): name = models.CharField(max_length=80) created = models.DateTimeField(auto_now_add=True) def __str__(self): return self.name class Post(models.Model): text = models.CharField(max_length=512) owner = models.ForeignKey('auth.User', related_name='posts', on_delete=models