Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
D
django
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
django
Commits
573ec714
Kaydet (Commit)
573ec714
authored
Ara 28, 2018
tarafından
Tim Graham
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Refs #25978 -- Removed shortcuts.render_to_response() per deprecation timeline.
üst
94446993
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
3 additions
and
113 deletions
+3
-113
shortcuts.py
django/shortcuts.py
+0
-17
3.0.txt
docs/releases/3.0.txt
+2
-0
shortcuts.txt
docs/topics/http/shortcuts.txt
+0
-11
test_render_to_response.py
tests/shortcuts/test_render_to_response.py
+0
-39
urls.py
tests/shortcuts/urls.py
+0
-5
views.py
tests/shortcuts/views.py
+1
-41
No files found.
django/shortcuts.py
Dosyayı görüntüle @
573ec714
...
...
@@ -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
...
...
docs/releases/3.0.txt
Dosyayı görüntüle @
573ec714
...
...
@@ -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.
...
...
docs/topics/http/shortcuts.txt
Dosyayı görüntüle @
573ec714
...
...
@@ -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()``
==============
...
...
tests/shortcuts/test_render_to_response.py
deleted
100644 → 0
Dosyayı görüntüle @
94446993
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
'
)
tests/shortcuts/urls.py
Dosyayı görüntüle @
573ec714
...
...
@@ -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
),
...
...
tests/shortcuts/views.py
Dosyayı görüntüle @
573ec714
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
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment