Python django rest框架的自定义查找_字段,无法解析详细信息

Python django rest框架的自定义查找_字段,无法解析详细信息,python,django,django-rest-framework,Python,Django,Django Rest Framework,我得到的错误是 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

我得到的错误是

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

class UserComboViewSet(viewsets.ModelViewSet):
    """
    API endpoint that allows UserCombo to be viewed or edited.
    """
    queryset = UserCombo.objects.all()
    serializer_class = UserComboSerializer
    permission_classes = (IsAuthenticated,EmailConfirmationPermission) 
    lookup_field='customURL'

    def get_queryset(self):
        return  UserCombo.objects.filter(user=self.request.user)
在my serializer.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。

看起来django rest framework 3.2版中将使用lookup_字段作为ModelSerializer.Meta的选项删除了。此错误是由于此删除。仍然可以将lookup_字段与额外的_Kwarg一起使用


确保
customURL
UserCombo
模型的一部分。定义
查找\u字段
-应用于执行单个模型实例的对象查找的模型字段。它是模型中的字符字段。