from rest_framework import serializers

from .models import Service, Category, ServicePhoto


class CategorySerializer(serializers.ModelSerializer):
    class Meta:
        model = Category
        fields = ('id', 'name', 'photo', 'order')


class ServicePhotoSerializer(serializers.ModelSerializer):
    """
    """
    class Meta:
        model = ServicePhoto
        fields = ('id', 'photo')


class ServiceSerializer(serializers.ModelSerializer):
    """ Usage:
        from rest_framework.renderers import JSONRenderer
        from semillas_backend.users.serializers import UserSerializer

        JSONRenderer().render(UserSerializer(user_instance).data)
    """
    category = CategorySerializer()
    photos = ServicePhotoSerializer(many=True)
    class Meta:
        model = Service
        fields = ('id', 'title', 'date', 'description', 'category', 'photos')

from rest_framework import serializers

from .models import Service, Category, ServicePhoto
from semillas_backend.users.serializers import UserSerializer


class CategorySerializer(serializers.ModelSerializer):
    class Meta:
        model = Category
        fields = ('id', 'name', 'photo', 'order')


class ServicePhotoSerializer(serializers.ModelSerializer):
    """
    """
    class Meta:
        model = ServicePhoto
        fields = ('id', 'photo')


class ServiceSerializer(serializers.ModelSerializer):
    """ Usage:
        from rest_framework.renderers import JSONRenderer
        from semillas_backend.users.serializers import UserSerializer

        JSONRenderer().render(UserSerializer(user_instance).data)
    """
    category = CategorySerializer()
    photos = ServicePhotoSerializer(many=True)
    author = UserSerializer()
    class Meta:
        model = Service
        fields = ('id', 'title', 'date', 'description', 'author', 'category', 'photos')

Add user serialized to ServiceSerializer
Add user serialized to ServiceSerializer

  from rest_framework import serializers
  
  from .models import Service, Category, ServicePhoto
+ from semillas_backend.users.serializers import UserSerializer
  
  
  class CategorySerializer(serializers.ModelSerializer):
      class Meta:
          model = Category
          fields = ('id', 'name', 'photo', 'order')
  
  
  class ServicePhotoSerializer(serializers.ModelSerializer):
      """
      """
      class Meta:
          model = ServicePhoto
          fields = ('id', 'photo')
  
  
  class ServiceSerializer(serializers.ModelSerializer):
      """ Usage:
          from rest_framework.renderers import JSONRenderer
          from semillas_backend.users.serializers import UserSerializer
  
          JSONRenderer().render(UserSerializer(user_instance).data)
      """
      category = CategorySerializer()
      photos = ServicePhotoSerializer(many=True)
+     author = UserSerializer()
      class Meta:
          model = Service
-         fields = ('id', 'title', 'date', 'description', 'category', 'photos')
+         fields = ('id', 'title', 'date', 'description', 'author', 'category', 'photos')
  
Add user serialized to ServiceSerializer
## Code Before:
from rest_framework import serializers

from .models import Service, Category, ServicePhoto


class CategorySerializer(serializers.ModelSerializer):
    class Meta:
        model = Category
        fields = ('id', 'name', 'photo', 'order')


class ServicePhotoSerializer(serializers.ModelSerializer):
    """
    """
    class Meta:
        model = ServicePhoto
        fields = ('id', 'photo')


class ServiceSerializer(serializers.ModelSerializer):
    """ Usage:
        from rest_framework.renderers import JSONRenderer
        from semillas_backend.users.serializers import UserSerializer

        JSONRenderer().render(UserSerializer(user_instance).data)
    """
    category = CategorySerializer()
    photos = ServicePhotoSerializer(many=True)
    class Meta:
        model = Service
        fields = ('id', 'title', 'date', 'description', 'category', 'photos')

## Instruction:
Add user serialized to ServiceSerializer
## Code After:
from rest_framework import serializers

from .models import Service, Category, ServicePhoto
from semillas_backend.users.serializers import UserSerializer


class CategorySerializer(serializers.ModelSerializer):
    class Meta:
        model = Category
        fields = ('id', 'name', 'photo', 'order')


class ServicePhotoSerializer(serializers.ModelSerializer):
    """
    """
    class Meta:
        model = ServicePhoto
        fields = ('id', 'photo')


class ServiceSerializer(serializers.ModelSerializer):
    """ Usage:
        from rest_framework.renderers import JSONRenderer
        from semillas_backend.users.serializers import UserSerializer

        JSONRenderer().render(UserSerializer(user_instance).data)
    """
    category = CategorySerializer()
    photos = ServicePhotoSerializer(many=True)
    author = UserSerializer()
    class Meta:
        model = Service
        fields = ('id', 'title', 'date', 'description', 'author', 'category', 'photos')
