diff options
Diffstat (limited to 'django/views')
| -rw-r--r-- | django/views/decorators/cache.py | 14 | ||||
| -rw-r--r-- | django/views/generic/list.py | 4 |
2 files changed, 4 insertions, 14 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 ) diff --git a/django/views/generic/list.py b/django/views/generic/list.py index 39dc856e55..61320fccbe 100644 --- a/django/views/generic/list.py +++ b/django/views/generic/list.py @@ -120,11 +120,11 @@ class MultipleObjectMixin(ContextMixin): else: return None - def get_context_data(self, **kwargs): + def get_context_data(self, *, object_list=None, **kwargs): """ Get the context for this view. """ - queryset = kwargs.pop('object_list', self.object_list) + queryset = object_list if object_list is not None else self.object_list page_size = self.get_paginate_by(queryset) context_object_name = self.get_context_object_name(queryset) if page_size: |
