diff options
| author | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2020-08-24 09:00:12 +0200 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2020-08-24 11:37:59 +0200 |
| commit | bb8f66934d93faf80cd1a2dda65aaedce21a6fc5 (patch) | |
| tree | a5f799b61d7335b561ae2eae5128e0e417bc8824 /django/views | |
| parent | 04e87e79a0bd2b1b9fdc30f884a637a3268733f0 (diff) | |
Fixed #31877 -- Reverted "Fixed #19878 -- Deprecated TemplateView passing URL kwargs into context."
This reverts commit 4ed534758cb6a11df9f49baddecca5a6cdda9311.
Diffstat (limited to 'django/views')
| -rw-r--r-- | django/views/generic/base.py | 30 |
1 files changed, 4 insertions, 26 deletions
diff --git a/django/views/generic/base.py b/django/views/generic/base.py index ea5baca08d..3dd957d8f8 100644 --- a/django/views/generic/base.py +++ b/django/views/generic/base.py @@ -1,5 +1,4 @@ import logging -import warnings from functools import update_wrapper from django.core.exceptions import ImproperlyConfigured @@ -10,8 +9,6 @@ from django.http import ( from django.template.response import TemplateResponse from django.urls import reverse from django.utils.decorators import classonlymethod -from django.utils.deprecation import RemovedInDjango40Warning -from django.utils.functional import SimpleLazyObject logger = logging.getLogger('django.request') @@ -155,33 +152,14 @@ class TemplateResponseMixin: class TemplateView(TemplateResponseMixin, ContextMixin, View): - """Render a template.""" + """ + Render a template. Pass keyword arguments from the URLconf to the context. + """ def get(self, request, *args, **kwargs): - # RemovedInDjango40Warning: when the deprecation ends, replace with: - # context = self.get_context_data() - context_kwargs = _wrap_url_kwargs_with_deprecation_warning(kwargs) - context = self.get_context_data(**context_kwargs) + context = self.get_context_data(**kwargs) return self.render_to_response(context) -# RemovedInDjango40Warning -def _wrap_url_kwargs_with_deprecation_warning(url_kwargs): - context_kwargs = {} - for key, value in url_kwargs.items(): - # Bind into function closure. - @SimpleLazyObject - def access_value(key=key, value=value): - warnings.warn( - 'TemplateView passing URL kwargs to the context is ' - 'deprecated. Reference %s in your template through ' - 'view.kwargs instead.' % key, - RemovedInDjango40Warning, stacklevel=2, - ) - return value - context_kwargs[key] = access_value - return context_kwargs - - class RedirectView(View): """Provide a redirect on any GET request.""" permanent = False |
