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
b748a8bc
Kaydet (Commit)
b748a8bc
authored
Kas 10, 2014
tarafından
Luke Plant
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed #23789 -- TemplateResponse handles context differently from render
üst
006451f8
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
28 additions
and
4 deletions
+28
-4
response.py
django/template/response.py
+4
-1
template-response.txt
docs/ref/template-response.txt
+4
-3
1.8.txt
docs/releases/1.8.txt
+14
-0
test_response.py
tests/template_tests/test_response.py
+6
-0
No files found.
django/template/response.py
Dosyayı görüntüle @
b748a8bc
...
...
@@ -154,4 +154,7 @@ class TemplateResponse(SimpleTemplateResponse):
"""
if
isinstance
(
context
,
Context
):
return
context
return
RequestContext
(
self
.
_request
,
context
,
current_app
=
self
.
_current_app
)
context_instance
=
RequestContext
(
self
.
_request
,
current_app
=
self
.
_current_app
)
if
context
:
context_instance
.
push
(
context
)
return
context_instance
docs/ref/template-response.txt
Dosyayı görüntüle @
b748a8bc
...
...
@@ -287,9 +287,10 @@ invoked immediately.
Using TemplateResponse and SimpleTemplateResponse
=================================================
A TemplateResponse object can be used anywhere that a normal
HttpResponse can be used. It can also be used as an alternative to
calling :func:`~django.shortcuts.render_to_response()`.
A TemplateResponse object can be used anywhere that a normal HttpResponse can be
used. It can also be used as an alternative to calling
:func:`~django.shortcuts.render()` or
:func:`~django.shortcuts.render_to_response()`.
For example, the following simple view returns a
:class:`TemplateResponse()` with a simple template, and a context
...
...
docs/releases/1.8.txt
Dosyayı görüntüle @
b748a8bc
...
...
@@ -640,6 +640,20 @@ run this query::
the serialization framework, that means that ``dumpdata`` output will now
contain the SRID value of geometry objects.
Priority of context processors for ``TemplateResponse`` brought in line with ``render``
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The :class:`~django.template.response.TemplateResponse` constructor is designed to be a
drop-in replacement for the :func:`~django.shortcuts.render` function. However,
it had a slight incompatibility, in that for ``TemplateResponse``, context data
from the passed in context dictionary could be shadowed by context data returned
from context processors, whereas for ``render`` it was the other way
around. This was a bug, and the behaviour of ``render`` is more appropriate,
since it allows the globally defined context processors to be overridden locally
in the view. If you were relying on the fact context data in a
``TemplateResponse`` could be overridden using a context processor, you will
need to change your code.
Miscellaneous
~~~~~~~~~~~~~
...
...
tests/template_tests/test_response.py
Dosyayı görüntüle @
b748a8bc
...
...
@@ -233,6 +233,12 @@ class TemplateResponseTest(TestCase):
Context
({
'foo'
:
'bar'
}))
.
render
()
self
.
assertEqual
(
response
.
content
,
b
'bar'
)
def
test_context_processor_priority
(
self
):
# context processors should be overridden by passed-in context
response
=
self
.
_response
(
'{{ foo }}{{ processors }}'
,
{
'processors'
:
'no'
})
.
render
()
self
.
assertEqual
(
response
.
content
,
b
'no'
)
def
test_kwargs
(
self
):
response
=
self
.
_response
(
content_type
=
'application/json'
,
status
=
504
)
...
...
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