Django REST:在POST中按段塞传递对象,但按id反序列化

Django REST:在POST中按段塞传递对象,但按id反序列化,django,django-models,django-rest-framework,Django,Django Models,Django Rest Framework,我一直在努力解决这个问题(对于Django Rest框架来说是相当新的) 示例模型 class BigModel(models.Model): id = models.AutoField(primary_key=True) something = models.CharField() nested = models.ForeignKey(SmallModel) class SmallModel(models.Model): id = models.AutoFie

我一直在努力解决这个问题(对于Django Rest框架来说是相当新的)

示例模型

class BigModel(models.Model):
    id = models.AutoField(primary_key=True)
    something = models.CharField()
    nested = models.ForeignKey(SmallModel)

class SmallModel(models.Model):
    id = models.AutoField(primary_key=True)
    name = models.CharField()
我基本上希望传递以下JSON

{"something": "whatever", "nested": "existing name" }
它将按给定字符串查找
SmallModel
,并在
BigModel
上设置正确的
nested_id

我知道这部分是
SlugRelatedField
的作用,但我没有运气让它起作用

我目前对序列化程序的看法如下(我基本上是手动查找):

有了这个,我得到了这个错误:

argument of type 'NoneType' is not iterable
这基本上意味着
是有效的()
在序列化程序上失败

如果
BigModelSerializer
上的
nested
字段设置为
PrimaryKeyRelatedField
,则验证甚至不会被调用

argument of type 'NoneType' is not iterable