I am trying to use the ETAG HTTP header to send 304 NOT MODIFIED responses. The following code is used:
class MyView(GenericAPIView):
serializer_class = MySerializer
@condition(etag_func=get_language_etag)
def get(self, request, *args, **kwargs):
return Response(self.get_cached_response())
The problem lies in the 'self' parameter of the get method. This jumbles the parameters in the @condition generator method here the beginning of the condition method:
def condition(etag_func=None, last_modified_func=None):
def decorator(func):
@wraps(func, assigned=available_attrs(func))
def inner(request, *args, **kwargs):
as now 'self' gets assigned to request and the actual requests ends up in *args.
Has anyone had a similar problem concerning decorators and their expected order of parameters?