small refactoring

This commit is contained in:
Anatoly 2019-12-06 17:37:33 +03:00
parent 8af8cf92e9
commit f1fa8a58de
2 changed files with 2 additions and 8 deletions

View File

@ -114,10 +114,7 @@ class EstablishmentCommentListView(generics.ListAPIView):
"""Override get_queryset method"""
establishment = get_object_or_404(models.Establishment, slug=self.kwargs['slug'])
return comment_models.Comment.objects.by_content_type(app_label='establishment',
model='establishment') \
.by_object_id(object_id=establishment.pk) \
.order_by('-created')
return establishment.comments.order_by('-created')
class EstablishmentCommentRUDView(generics.RetrieveUpdateDestroyAPIView):

View File

@ -60,10 +60,7 @@ class ProductCommentListView(generics.ListAPIView):
def get_queryset(self):
"""Override get_queryset method"""
product = get_object_or_404(Product, slug=self.kwargs['slug'])
return Comment.objects.by_content_type(app_label='product',
model='product') \
.by_object_id(object_id=product.pk) \
.order_by('-created')
return product.comments.order_by('-created')
class ProductCommentRUDView(generics.RetrieveUpdateDestroyAPIView):