from django.contrib.auth.models import User, Group
from waterfall_wall.models import Image
from rest_framework import serializers


class ImageSerializer(serializers.HyperlinkedModelSerializer):
    class Meta:
        model = Image
        fields = ('path', 'url', 'nude_percent')

from django.contrib.auth.models import User, Group
from waterfall_wall.models import Image
from rest_framework import serializers


class ImageSerializer(serializers.HyperlinkedModelSerializer):
    url = serializers.SerializerMethodField()

    def get_url(self, obj):
        return obj.path.url

    class Meta:
        model = Image
        fields = ('url', 'nude_percent')

Correct the url format of image API
Correct the url format of image API

  from django.contrib.auth.models import User, Group
  from waterfall_wall.models import Image
  from rest_framework import serializers
  
  
  class ImageSerializer(serializers.HyperlinkedModelSerializer):
+     url = serializers.SerializerMethodField()
+ 
+     def get_url(self, obj):
+         return obj.path.url
+ 
      class Meta:
          model = Image
-         fields = ('path', 'url', 'nude_percent')
+         fields = ('url', 'nude_percent')
  
Correct the url format of image API
## Code Before:
from django.contrib.auth.models import User, Group
from waterfall_wall.models import Image
from rest_framework import serializers


class ImageSerializer(serializers.HyperlinkedModelSerializer):
    class Meta:
        model = Image
        fields = ('path', 'url', 'nude_percent')

## Instruction:
Correct the url format of image API
## Code After:
from django.contrib.auth.models import User, Group
from waterfall_wall.models import Image
from rest_framework import serializers


class ImageSerializer(serializers.HyperlinkedModelSerializer):
    url = serializers.SerializerMethodField()

    def get_url(self, obj):
        return obj.path.url

    class Meta:
        model = Image
        fields = ('url', 'nude_percent')
