Optimize queryset
This commit is contained in:
parent
d86855d579
commit
466e62066f
@ -1,5 +1,5 @@
|
|||||||
from rest_framework.decorators import action
|
from rest_framework.decorators import action
|
||||||
from rest_framework.permissions import AllowAny, IsAdminUser, IsAuthenticated
|
from rest_framework.permissions import AllowAny, IsAuthenticated
|
||||||
from rest_framework.response import Response
|
from rest_framework.response import Response
|
||||||
from rest_framework.viewsets import ModelViewSet
|
from rest_framework.viewsets import ModelViewSet
|
||||||
|
|
||||||
@ -52,7 +52,12 @@ class ProductViewset(ActionBasedMixin, ModelViewSet):
|
|||||||
|
|
||||||
|
|
||||||
class PostViewset(ActionBasedMixin, ModelViewSet):
|
class PostViewset(ActionBasedMixin, ModelViewSet):
|
||||||
queryset = Post.objects.all()
|
queryset = Post.objects.all().select_related(
|
||||||
|
"storage",
|
||||||
|
"product",
|
||||||
|
"author",
|
||||||
|
"product__brand",
|
||||||
|
)
|
||||||
serializer_class = PostSerializer
|
serializer_class = PostSerializer
|
||||||
permission_classes = [IsAuthenticated, IsAuthorOrReadOnly]
|
permission_classes = [IsAuthenticated, IsAuthorOrReadOnly]
|
||||||
permission_classes_map = {
|
permission_classes_map = {
|
||||||
|
Loading…
Reference in New Issue
Block a user