from rest_framework import viewsets
from api.models import Card, Collection
from api.serializers import CardSerializer, CollectionSerializer
from django_filters.rest_framework import DjangoFilterBackend


class CardViewSet(viewsets.ModelViewSet):
    queryset = Card.objects.all()
    serializer_class = CardSerializer
    filter_backends = [DjangoFilterBackend]
    filterset_fields = ["collection__name"]


class CollectionViewSet(viewsets.ModelViewSet):
    queryset = Collection.objects.all()
    serializer_class = CollectionSerializer
