diff options
| author | Aymeric Augustin <aymeric.augustin@m4x.org> | 2014-12-14 17:48:51 +0100 |
|---|---|---|
| committer | Aymeric Augustin <aymeric.augustin@m4x.org> | 2014-12-28 17:02:29 +0100 |
| commit | cf1f36bb6eb34fafe6c224003ad585a647f6117b (patch) | |
| tree | 7e3714ca48a6456ba5d3ebed2fc873f9ff0e6dc6 /django/shortcuts.py | |
| parent | e53495ba3352c2c0fdb6178f2b333c30cb6b5d46 (diff) | |
Deprecated current_app in TemplateResponse and render(_to_response).
Diffstat (limited to 'django/shortcuts.py')
| -rw-r--r-- | django/shortcuts.py | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/django/shortcuts.py b/django/shortcuts.py index 780f89a6b5..a8f7278bcb 100644 --- a/django/shortcuts.py +++ b/django/shortcuts.py @@ -3,6 +3,9 @@ This module collects helper functions and classes that "span" multiple levels of MVC. In other words, these functions/classes introduce controlled coupling for convenience's sake. """ + +import warnings + from django.template import loader, RequestContext from django.template.context import _current_app_undefined from django.template.engine import ( @@ -14,6 +17,7 @@ from django.db.models.manager import Manager from django.db.models.query import QuerySet from django.core import urlresolvers from django.utils import six +from django.utils.deprecation import RemovedInDjango20Warning def render_to_response(template_name, context=None, @@ -61,7 +65,16 @@ def render(request, template_name, context=None, raise ValueError('If you provide a context_instance you must ' 'set its current_app before calling render()') else: - context_instance = RequestContext(request, current_app=current_app) + context_instance = RequestContext(request) + if current_app is not _current_app_undefined: + warnings.warn( + "The current_app argument of render is deprecated. " + "Set the current_app attribute of request instead.", + RemovedInDjango20Warning, stacklevel=2) + request.current_app = current_app + # Directly set the private attribute to avoid triggering the + # warning in RequestContext.__init__. + context_instance._current_app = current_app content = loader.render_to_string( template_name, context, context_instance, dirs, dictionary) |
