You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
21 lines
569 B
21 lines
569 B
from rest_framework import viewsets
|
|
|
|
from .serializers import CategorySerializer, CourseSerializer
|
|
from . import ExtendedModelViewSet
|
|
|
|
from apps.course.models import Category, Course
|
|
|
|
|
|
class CategoryViewSet(ExtendedModelViewSet):
|
|
queryset = Category.objects.all()
|
|
serializer_class = CategorySerializer
|
|
|
|
|
|
class CourseViewSet(ExtendedModelViewSet):
|
|
queryset = Course.objects.select_related(
|
|
'author', 'category'
|
|
).prefetch_related(
|
|
'likes', 'materials'
|
|
).all()
|
|
serializer_class = CourseSerializer
|
|
filter_fields = ('category',)
|
|
|