from rest_framework import serializers
from .models import Student

class StudentSerializer(serializers.HyperlinkedModelSerializer):    
   # name = serializers.CharField(read_only=True) #read_only single field
    class Meta:
        model = Student
        fields = ['id','url','name','roll','city']
        # read_only_fields = ['name','roll'] # Multiple read_only Method 1        
        # Multiple read_only Method 2
        # extra_kwargs = {'name':{'read_only':True},'roll':{'read_only':True}}

   
d3b0f2815b213c5ae41fff206b463db0c1d6ad9e
<mask token>

<mask token>


class StudentSerializer(serializers.HyperlinkedModelSerializer):


    class Meta:
        model = Student
        fields = ['id', 'url', 'name', 'roll', 'city']

from rest_framework import serializers
from .models import Student


class StudentSerializer(serializers.HyperlinkedModelSerializer):


    class Meta:
        model = Student
        fields = ['id', 'url', 'name', 'roll', 'city']

from rest_framework import serializers
from .models import Student

class StudentSerializer(serializers.HyperlinkedModelSerializer):    
   # name = serializers.CharField(read_only=True) #read_only single field
    class Meta:
        model = Student
        fields = ['id','url','name','roll','city']
        # read_only_fields = ['name','roll'] # Multiple read_only Method 1        
        # Multiple read_only Method 2
        # extra_kwargs = {'name':{'read_only':True},'roll':{'read_only':True}}

   