summaryrefslogtreecommitdiff
path: root/django/views/decorators/cache.py
diff options
context:
space:
mode:
Diffstat (limited to 'django/views/decorators/cache.py')
-rw-r--r--django/views/decorators/cache.py14
1 files changed, 2 insertions, 12 deletions
diff --git a/django/views/decorators/cache.py b/django/views/decorators/cache.py
index 18238aaae7..7c5d157ea5 100644
--- a/django/views/decorators/cache.py
+++ b/django/views/decorators/cache.py
@@ -5,7 +5,7 @@ from django.utils.cache import add_never_cache_headers, patch_cache_control
from django.utils.decorators import decorator_from_middleware_with_args
-def cache_page(*args, **kwargs):
+def cache_page(timeout, *, cache=None, key_prefix=None):
"""
Decorator for views that tries getting the page from the cache and
populates the cache if the page isn't in the cache yet.
@@ -19,18 +19,8 @@ def cache_page(*args, **kwargs):
Additionally, all headers from the response's Vary header will be taken
into account on caching -- just like the middleware does.
"""
- # We also add some asserts to give better error messages in case people are
- # using other ways to call cache_page that no longer work.
- if len(args) != 1 or callable(args[0]):
- raise TypeError("cache_page has a single mandatory positional argument: timeout")
- cache_timeout = args[0]
- cache_alias = kwargs.pop('cache', None)
- key_prefix = kwargs.pop('key_prefix', None)
- if kwargs:
- raise TypeError("cache_page has two optional keyword arguments: cache and key_prefix")
-
return decorator_from_middleware_with_args(CacheMiddleware)(
- cache_timeout=cache_timeout, cache_alias=cache_alias, key_prefix=key_prefix
+ cache_timeout=timeout, cache_alias=cache, key_prefix=key_prefix
)