recipes_api/app/recipe/serializers.py
devfzn 40bbaff60b
creación TAG API
test, model, list, serializers, views & urls
2023-10-10 00:08:52 -03:00

35 lines
739 B
Python

"""
Serializers for recipe APIs
"""
from rest_framework import serializers
from core.models import (
Recipe,
Tag,
)
class RecipeSerializer(serializers.ModelSerializer):
"""Serializer for recipes."""
class Meta:
model = Recipe
fields = ['id', 'title', 'time_minutes', 'price', 'link']
read_only_fields = ['id']
class RecipeDetailSerializer(RecipeSerializer):
"""Serializer for recipe detail view."""
class Meta(RecipeSerializer.Meta):
fields = RecipeSerializer.Meta.fields + ['description']
class TagSerializer(serializers.ModelSerializer):
"""Serializer for tags."""
class Meta:
model = Tag
fields = ['id', 'name']
read_only_fields = ['id']