Запрос выглядит следующим образом:
Код: Выделить всё
GET /products?producent=some_company
Код: Выделить всё
class ProductsListCreate(generics.ListCreateAPIView):
def list(self, request, *args, **kwargs):
producent = request.query_params.get("producent")
cached_response = cache.get(f"response-products-{producent}", None)
if not cached_response:
queryset = self.filter_queryset(self.get_queryset())
page = self.paginate_queryset(queryset)
serializer = self.get_serializer(page)
response = self.get_paginated_response(serializer.data)
cache.set(f"response-products-{producent}", response , timeout=20)
return response
return cached_response
Код: Выделить всё
django.template.response.ContentNotRenderedError: The response content must be rendered before it can be pickled.
Подробнее здесь: https://stackoverflow.com/questions/702 ... om-request
Мобильная версия