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.
 
 

29 lines
932 B

from rest_framework.permissions import IsAuthenticated
from rest_framework.response import Response
from django.db.models import Subquery, Count, F, OuterRef, Q, Prefetch
from rest_framework.generics import ListAPIView
from apps.hadis.models import *
from apps.hadis.serializers import *
from apps.hadis.doc import category_list_swagger, category_hadis_list_swagger
class CategoryHadisListView(ListAPIView):
serializer_class = HadisSerializer
permission_classes = (IsAuthenticated,)
@category_hadis_list_swagger
def get(self, request, *args, **kwargs):
return super().get(request, *args, **kwargs)
def get_queryset(self):
categories = HadisCategory.objects.filter(id=self.kwargs['pk']).order_by('-order')
return Hadis.objects.filter(
Q(category__in=categories),
status=True,
).prefetch_related(
'category',
'tags',
)