text: from rest_framework import serializers
  from core.models import Tag, Ingriedient, Recipe
  
  
  class TagSerializer(serializers.ModelSerializer):
      """Serializer for tag objects"""
  
      class Meta:
          model = Tag
          fields = ('id', 'name')
          read_only_fields = ('id',)
  
  
  class IngriedientSerializer(serializers.ModelSerializer):
      """Serializer for ingredient serializer objects"""
  
      class Meta:
          model = Ingriedient
          fields = ('id', 'name')
          read_only_fields = ('id',)
  
  
  class RecipeSerializer(serializers.ModelSerializer):
      """Serializer a recipe"""
      ingriedients = serializers.PrimaryKeyRelatedField(
          many=True,
          queryset=Ingriedient.objects.all()
      )
      tags = serializers.PrimaryKeyRelatedField(
          many=True,
          queryset=Tag.objects.all()
      )
  
      class Meta:
          model = Recipe
          fields = ('id', 'title', 'ingriedients', 'tags', 'time_minutes',
                    'price', 'link')
          read_only_fields = ('id',)
  
  
  class RecipeDetailSerializer(RecipeSerializer):
      """Serializer a recipe detail"""
      ingriedients = IngriedientSerializer(many=True, read_only=True)
      tags = TagSerializer(many=True, read_only=True)
  
  
  class RecipeImageSerializer(serializers.ModelSerializer):
      """Serializer for uploading image to recipes"""
  
      class Meta:
          model = Recipe
          fields = ('id', 'image')
          read_only_fields = ('id',)
  