django.utils.decorators.decorator_from_middleware doesn't work for decorators with parameters:
- Any parameter of decorator causes a call to _decorator_from_middleware().
- Instead of actual wrapping _wrapped_view() is called, which fails because at that point request is actually a view function.
Basically this works:
@cache_page
def my_cool_view(request):
# cool processing
This doesn't:
@cache_page(60)
def my_cool_view(request):
# cool processing
Nor this:
@cache_page(cache_timeout=60)
def my_cool_view(request):
# cool processing
Just try it.
If this is an intended behavior, we need to update documentation for @cache_page. (I didn't check if there is a documentation for @gzip_page and @conditional_page).
It makes sense to document that per-page caching still uses CACHE_MIDDLEWARE_SECONDS and CACHE_MIDDLEWARE_KEY_PREFIX, if no decorator arguments were given. And currently it is impossible to specify them.