summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Graham <timograham@gmail.com>2018-12-27 19:23:09 -0500
committerTim Graham <timograham@gmail.com>2019-01-17 10:50:25 -0500
commit573ec714e5f52eccde01bbac3836d0edafcb2c20 (patch)
tree21c38c525773f24963afea76135715e5086147d5
parent944469939b9eb93fda0924f78faba5c0ffae2dff (diff)
Refs #25978 -- Removed shortcuts.render_to_response() per deprecation timeline.
-rw-r--r--django/shortcuts.py17
-rw-r--r--docs/releases/3.0.txt2
-rw-r--r--docs/topics/http/shortcuts.txt11
-rw-r--r--tests/shortcuts/test_render_to_response.py39
-rw-r--r--tests/shortcuts/urls.py5
-rw-r--r--tests/shortcuts/views.py42
6 files changed, 3 insertions, 113 deletions
diff --git a/django/shortcuts.py b/django/shortcuts.py
index 7ab1df0e9d..eda6f8813c 100644
--- a/django/shortcuts.py
+++ b/django/shortcuts.py
@@ -3,31 +3,14 @@ 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.http import (
Http404, HttpResponse, HttpResponsePermanentRedirect, HttpResponseRedirect,
)
from django.template import loader
from django.urls import NoReverseMatch, reverse
-from django.utils.deprecation import RemovedInDjango30Warning
from django.utils.functional import Promise
-def render_to_response(template_name, context=None, content_type=None, status=None, using=None):
- """
- Return a HttpResponse whose content is filled with the result of calling
- django.template.loader.render_to_string() with the passed arguments.
- """
- warnings.warn(
- 'render_to_response() is deprecated in favor of render(). It has the '
- 'same signature except that it also requires a request.',
- RemovedInDjango30Warning, stacklevel=2,
- )
- content = loader.render_to_string(template_name, context, using=using)
- return HttpResponse(content, content_type, status)
-
-
def render(request, template_name, context=None, content_type=None, status=None, using=None):
"""
Return a HttpResponse whose content is filled with the result of calling
diff --git a/docs/releases/3.0.txt b/docs/releases/3.0.txt
index 4639706146..c07a995bd6 100644
--- a/docs/releases/3.0.txt
+++ b/docs/releases/3.0.txt
@@ -238,6 +238,8 @@ to remove usage of these features.
* The ``django.db.backends.postgresql_psycopg2`` module is removed.
+* ``django.shortcuts.render_to_response()`` is removed.
+
See :ref:`deprecated-features-2.1` for details on these changes, including how
to remove usage of these features.
diff --git a/docs/topics/http/shortcuts.txt b/docs/topics/http/shortcuts.txt
index 1aca4ce287..a0eac39012 100644
--- a/docs/topics/http/shortcuts.txt
+++ b/docs/topics/http/shortcuts.txt
@@ -81,17 +81,6 @@ This example is equivalent to::
c = {'foo': 'bar'}
return HttpResponse(t.render(c, request), content_type='application/xhtml+xml')
-``render_to_response()``
-========================
-
-.. function:: render_to_response(template_name, context=None, content_type=None, status=None, using=None)
-
- .. deprecated:: 2.0
-
- This function preceded the introduction of :func:`render` and works
- similarly except that it doesn't make the ``request`` available in the
- response.
-
``redirect()``
==============
diff --git a/tests/shortcuts/test_render_to_response.py b/tests/shortcuts/test_render_to_response.py
deleted file mode 100644
index 7bf7ac9ad6..0000000000
--- a/tests/shortcuts/test_render_to_response.py
+++ /dev/null
@@ -1,39 +0,0 @@
-from django.test import SimpleTestCase, ignore_warnings, override_settings
-from django.test.utils import require_jinja2
-from django.utils.deprecation import RemovedInDjango30Warning
-
-
-@ignore_warnings(category=RemovedInDjango30Warning)
-@override_settings(ROOT_URLCONF='shortcuts.urls')
-class RenderToResponseTests(SimpleTestCase):
-
- def test_render_to_response(self):
- response = self.client.get('/render_to_response/')
- self.assertEqual(response.status_code, 200)
- self.assertEqual(response.content, b'FOO.BAR..\n')
- self.assertEqual(response['Content-Type'], 'text/html; charset=utf-8')
-
- def test_render_to_response_with_multiple_templates(self):
- response = self.client.get('/render_to_response/multiple_templates/')
- self.assertEqual(response.status_code, 200)
- self.assertEqual(response.content, b'FOO.BAR..\n')
-
- def test_render_to_response_with_content_type(self):
- response = self.client.get('/render_to_response/content_type/')
- self.assertEqual(response.status_code, 200)
- self.assertEqual(response.content, b'FOO.BAR..\n')
- self.assertEqual(response['Content-Type'], 'application/x-rendertest')
-
- def test_render_to_response_with_status(self):
- response = self.client.get('/render_to_response/status/')
- self.assertEqual(response.status_code, 403)
- self.assertEqual(response.content, b'FOO.BAR..\n')
-
- @require_jinja2
- def test_render_to_response_with_using(self):
- response = self.client.get('/render_to_response/using/')
- self.assertEqual(response.content, b'DTL\n')
- response = self.client.get('/render_to_response/using/?using=django')
- self.assertEqual(response.content, b'DTL\n')
- response = self.client.get('/render_to_response/using/?using=jinja2')
- self.assertEqual(response.content, b'Jinja2\n')
diff --git a/tests/shortcuts/urls.py b/tests/shortcuts/urls.py
index 0ac994b7d3..a506896bcf 100644
--- a/tests/shortcuts/urls.py
+++ b/tests/shortcuts/urls.py
@@ -3,11 +3,6 @@ from django.urls import path
from . import views
urlpatterns = [
- path('render_to_response/', views.render_to_response_view),
- path('render_to_response/multiple_templates/', views.render_to_response_view_with_multiple_templates),
- path('render_to_response/content_type/', views.render_to_response_view_with_content_type),
- path('render_to_response/status/', views.render_to_response_view_with_status),
- path('render_to_response/using/', views.render_to_response_view_with_using),
path('render/', views.render_view),
path('render/multiple_templates/', views.render_view_with_multiple_templates),
path('render/content_type/', views.render_view_with_content_type),
diff --git a/tests/shortcuts/views.py b/tests/shortcuts/views.py
index 6914a5e395..bba17b3eea 100644
--- a/tests/shortcuts/views.py
+++ b/tests/shortcuts/views.py
@@ -1,44 +1,4 @@
-from django.shortcuts import render, render_to_response
-
-
-def render_to_response_view(request):
- return render_to_response('shortcuts/render_test.html', {
- 'foo': 'FOO',
- 'bar': 'BAR',
- })
-
-
-def render_to_response_view_with_multiple_templates(request):
- return render_to_response([
- 'shortcuts/no_such_template.html',
- 'shortcuts/render_test.html',
- ], {
- 'foo': 'FOO',
- 'bar': 'BAR',
- })
-
-
-def render_to_response_view_with_content_type(request):
- return render_to_response('shortcuts/render_test.html', {
- 'foo': 'FOO',
- 'bar': 'BAR',
- }, content_type='application/x-rendertest')
-
-
-def render_to_response_view_with_status(request):
- return render_to_response('shortcuts/render_test.html', {
- 'foo': 'FOO',
- 'bar': 'BAR',
- }, status=403)
-
-
-def render_to_response_view_with_using(request):
- using = request.GET.get('using')
- return render_to_response('shortcuts/using.html', using=using)
-
-
-def context_processor(request):
- return {'bar': 'context processor output'}
+from django.shortcuts import render
def render_view(request):