from rest_framework import serializers
from quotedb.models import Quote


class QuoteSerializer(serializers.ModelSerializer):
    owner = serializers.ReadOnlyField(source='owner.username')

    class Meta:
        model = Quote
        fields = ('body', 'owner', 'created', 'approved')

from rest_framework import serializers
from quotedb.models import Quote


class QuoteSerializer(serializers.ModelSerializer):
    owner = serializers.ReadOnlyField(source='owner.username')

    class Meta:
        model = Quote
        fields = ('id', 'body', 'owner', 'created', 'approved')
        read_only = ('id',)

Add id to api results
Add id to api results

  from rest_framework import serializers
  from quotedb.models import Quote
  
  
  class QuoteSerializer(serializers.ModelSerializer):
      owner = serializers.ReadOnlyField(source='owner.username')
  
      class Meta:
          model = Quote
-         fields = ('body', 'owner', 'created', 'approved')
+         fields = ('id', 'body', 'owner', 'created', 'approved')
+         read_only = ('id',)
  
Add id to api results
## Code Before:
from rest_framework import serializers
from quotedb.models import Quote


class QuoteSerializer(serializers.ModelSerializer):
    owner = serializers.ReadOnlyField(source='owner.username')

    class Meta:
        model = Quote
        fields = ('body', 'owner', 'created', 'approved')

## Instruction:
Add id to api results
## Code After:
from rest_framework import serializers
from quotedb.models import Quote


class QuoteSerializer(serializers.ModelSerializer):
    owner = serializers.ReadOnlyField(source='owner.username')

    class Meta:
        model = Quote
        fields = ('id', 'body', 'owner', 'created', 'approved')
        read_only = ('id',)
