2023-10-09 03:25:09 -03:00
|
|
|
"""
|
|
|
|
Serializers for recipe APIs
|
|
|
|
"""
|
|
|
|
from rest_framework import serializers
|
|
|
|
|
|
|
|
from core.models import Recipe
|
|
|
|
|
|
|
|
|
|
|
|
class RecipeSerializer(serializers.ModelSerializer):
|
|
|
|
"""Serializer for recipes."""
|
|
|
|
|
|
|
|
class Meta:
|
|
|
|
model = Recipe
|
|
|
|
fields = ['id', 'title', 'time_minutes', 'price', 'link']
|
|
|
|
read_only_fields = ['id']
|
2023-10-09 15:34:58 -03:00
|
|
|
|
|
|
|
|
|
|
|
class RecipeDetailSerializer(RecipeSerializer):
|
|
|
|
"""Serializer for recipe detail view."""
|
|
|
|
|
|
|
|
class Meta(RecipeSerializer.Meta):
|
|
|
|
fields = RecipeSerializer.Meta.fields + ['description']
|