[Django]-Struggling to get django_comments to work with Django REST Framework

4👍

In your Comment serializer, specify comment instances fields explicitly and exclude field contenttype.

class CommentSerializer(serializers.HyperlinkedModelSerializer):
    class Meta:
        model = Comment
        fields = ('field_1','field_2','field_3') #here goes your comment fields and dont include contenttype field

The problem is that DRF will try to apply hyperlinks to represent all relationships, and for contenttype field you don’t have a view or a serializer and you dont need it either.

👤levi

Leave a comment