Dean Christian Armada
Dean Christian Armada

Reputation: 7384

Include all fields in HyperLinkedModelSerializer of Django Rest Framework

I am trying to include all fields on my HyperLinkedSerializer but I got no luck on making it work, as well as, searching for answers.

I got these two codes which did not work:

from django.contrib.auth.models import User

from rest_framework import serializers

# Serializers define the API representation.
class UserSerializer(serializers.HyperlinkedModelSerializer):
    class Meta:
        model = User
        fields = '__all__'


from django.contrib.auth.models import User

from rest_framework import serializers

# Serializers define the API representation.
class UserSerializer(serializers.HyperlinkedModelSerializer):
    class Meta:
        model = User

Upvotes: 0

Views: 630

Answers (1)

Luan Oliveira
Luan Oliveira

Reputation: 338

I didn't understand why you are using HyperlinkedModelSerializer if you aren't using relations. You must to use this when you have OneTo* or manyTo*.

If no, use ModelSerializer

Upvotes: 2

Related Questions