2👍
drf-extensions provides caching and ETag mixins that you can use on your views, instead of using the ones provided by Django.
https://chibisov.github.io/drf-extensions/docs/#cache-etag-mixins
It is not possible to use the methods provided by Django before DRF does not use the standard HttpResponse
classes, and most of the decorators are expecting it.
2👍
You can use django-rest-framework-condition
Install it:
pip install django-rest-framework-condition
Use it in the same way as decorator from Django:
from rest_framework_condition import condition
class MyView(GenericAPIView):
serializer_class = MySerializer
@condition(etag_func=get_language_etag)
def get(self, request, *args, **kwargs):
return Response(self.get_cached_response())
👤jozo
- [Django]-Lots of socket errors with celery eventlet tasks
- [Django]-Django admin – how to change choices in inlines?
- [Django]-What is robots.txt warning in django and advise to handle this?
- [Django]-Get nested serialized data as one
- [Django]-404 GET (Trying to use Tornado Server to serve static files):
Source:stackexchange.com