diff options
| author | Aymeric Augustin <aymeric.augustin@m4x.org> | 2014-11-28 23:50:34 +0100 |
|---|---|---|
| committer | Aymeric Augustin <aymeric.augustin@m4x.org> | 2014-12-28 16:23:02 +0100 |
| commit | 90805b240fdb1a1570c414f7d55fa1b0b77e1f24 (patch) | |
| tree | 4f3fcccb3b8709c54eb2c7a1e00967694e25390f /django/shortcuts.py | |
| parent | f9a6ebf6f5c8e1723db680bf6d462a9df8889d7f (diff) | |
Supported multiple template engines in render_to_string.
Adjusted its API through a deprecation path according to the DEP.
Diffstat (limited to 'django/shortcuts.py')
| -rw-r--r-- | django/shortcuts.py | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/django/shortcuts.py b/django/shortcuts.py index 62560472c1..d1c0770af9 100644 --- a/django/shortcuts.py +++ b/django/shortcuts.py @@ -3,6 +3,8 @@ 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.http import HttpResponse, Http404 from django.http import HttpResponseRedirect, HttpResponsePermanentRedirect @@ -11,6 +13,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(*args, **kwargs): @@ -20,7 +23,12 @@ def render_to_response(*args, **kwargs): """ httpresponse_kwargs = {'content_type': kwargs.pop('content_type', None)} - return HttpResponse(loader.render_to_string(*args, **kwargs), **httpresponse_kwargs) + # TODO: refactor to avoid the deprecated code path. + with warnings.catch_warnings(): + warnings.filterwarnings("ignore", category=RemovedInDjango20Warning) + content = loader.render_to_string(*args, **kwargs) + + return HttpResponse(content, **httpresponse_kwargs) def render(request, *args, **kwargs): @@ -45,8 +53,12 @@ def render(request, *args, **kwargs): kwargs['context_instance'] = context_instance - return HttpResponse(loader.render_to_string(*args, **kwargs), - **httpresponse_kwargs) + # TODO: refactor to avoid the deprecated code path. + with warnings.catch_warnings(): + warnings.filterwarnings("ignore", category=RemovedInDjango20Warning) + content = loader.render_to_string(*args, **kwargs) + + return HttpResponse(content, **httpresponse_kwargs) def redirect(to, *args, **kwargs): |
