我得到的错误是
ImproperlyConfigured at /usercombo/
Could not resolve URL for hyperlinked relationship using view name "usercombo-detail". You may have failed to include the related model in your API, or incorrectly configured the `lookup_field` attribute on this field.
在我的视图.py在
^{pr2}$在我的序列化程序.py公司名称:
class UserCombo(serializers.HyperlinkedModelSerializer):
customURL = serializers.CharField(
required=False,)
data = JSONSerializerField()
class Meta:
model = UserCombo
unique_together = (("product", "user"),)
fields = ('url', 'user', 'product', 'data', 'customURL', 'is_active')
lookup_field ='customURL'
如果我删除两个lookup_字段行,一切正常,但是usercombo对象的lookup_字段是pk。在
似乎已将“使用查找”字段作为选项删除ModelSerializer.Meta在django rest framework3.2版中。此错误是因为此删除。仍然可以将查找字段与额外的\u kwargs一起使用。在
http://www.django-rest-framework.org/topics/3.2-announcement/
相关问题 更多 >
编程相关推荐