2👍
✅
You can define the decorator inside the custom_cache_page
, like:
from functools import wraps
def custom_cache_page(timeout, *, cache=None, key_prefix=None):
callto = decorator_from_middleware_with_args(CacheMiddleware)(
page_timeout=85,
cache_alias=cache,
key_prefix=key_prefix,
)
def decorator(view):
@wraps(view)
def f(request, *args, **kwargs):
print(request)
return callto(view)(request, *args, **kwargs)
return f
return decorator
Source:stackexchange.com