from rest_framework import serializers
# Serializer will look at models and convert them to JSON for us

from .models import List, Card #our models

# Have to load CardSerializer before List for order of operations
class CardSerializer(serializers.ModelSerializer):
    # Model we are representing is Card
    class Meta:
        model = Card
        fields = '__all__'

class ListSerializer(serializers.ModelSerializer):
    # pulls the cards into the serializer
    cards = CardSerializer(read_only=True, many=True)

    # Model we are representing is List
    class Meta:
        model = List
        fields = '__all__' # Now required in django/rest_framework
