我创建了一个函数makeList来将项目插入列表。每当我尝试通过邮递员检查POST请求的API时,都会收到以下错误消息
null value in column "list_name" violates not-null constraint DETAIL: Failing row contains (16, null).
查看功能
if request.method == 'POST':
list_item = request.POST.get('list_item')
ListCategory.objects.create(list_name=list_item)
# return something not yet decided
full_list = ListCategory.objects.order_by('id')
full_list = serializers.serialize('json',full_list)
return HttpResponse(full_list, content_type='application/json')
模型ListCategory
class ListCategory(models.Model):
# user_id = models.IntegerField()
list_name = models.CharField(max_length=200)
def __str__(self):
return self.list_name
邮递员上面的屏幕截图