[Fixed]-Type object 'UploadSerializers' has no attribute 'HyperlinkedModelSerializer'

1👍

You’ve inherited your UploadSerializer class from serializers.ModelSerializer, not from serializers.HyperLinkedModelSerializer

class UploadSerializers(serializers.ModelSerializer):
    class Meta:
        model = Upload
        fields = ('image',)

So when you try to use it as

uploads = UploadSerializers.HyperlinkedModelSerializer(many=True,read_only=True)

it doesn’t have that attribute.

If you make your initial declaration of UploadSerializers inherit from the hyperlink class, it should work.

class UploadSerializers(serializers.HyperlinkedModelSerializer):
    class Meta:
        model = Upload
        fields = ('image',)

Then you should be able to use:

uploads = UploadSerializers(many=True,read_only=True)

Leave a comment