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
03e1cc93
Kaydet (Commit)
03e1cc93
authored
Nis 09, 2016
tarafından
Mounir Messelmeni
Kaydeden (comit)
Tim Graham
Nis 09, 2016
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed #26145 -- Made debug context processor return queries for all databases.
üst
9e3f1417
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
27 additions
and
5 deletions
+27
-5
context_processors.py
django/template/context_processors.py
+7
-2
api.txt
docs/ref/templates/api.txt
+7
-2
1.10.txt
docs/releases/1.10.txt
+3
-0
debug.html
...ontext_processors/templates/context_processors/debug.html
+4
-0
tests.py
tests/context_processors/tests.py
+2
-0
views.py
tests/context_processors/views.py
+4
-1
No files found.
django/template/context_processors.py
Dosyayı görüntüle @
03e1cc93
...
@@ -9,6 +9,8 @@ of a DjangoTemplates backend and used by RequestContext.
...
@@ -9,6 +9,8 @@ of a DjangoTemplates backend and used by RequestContext.
from
__future__
import
unicode_literals
from
__future__
import
unicode_literals
import
itertools
from
django.conf
import
settings
from
django.conf
import
settings
from
django.middleware.csrf
import
get_token
from
django.middleware.csrf
import
get_token
from
django.utils.encoding
import
smart_text
from
django.utils.encoding
import
smart_text
...
@@ -40,10 +42,13 @@ def debug(request):
...
@@ -40,10 +42,13 @@ def debug(request):
context_extras
=
{}
context_extras
=
{}
if
settings
.
DEBUG
and
request
.
META
.
get
(
'REMOTE_ADDR'
)
in
settings
.
INTERNAL_IPS
:
if
settings
.
DEBUG
and
request
.
META
.
get
(
'REMOTE_ADDR'
)
in
settings
.
INTERNAL_IPS
:
context_extras
[
'debug'
]
=
True
context_extras
[
'debug'
]
=
True
from
django.db
import
connection
from
django.db
import
connection
s
# Return a lazy reference that computes connection.queries on access,
# Return a lazy reference that computes connection.queries on access,
# to ensure it contains queries triggered after this function runs.
# to ensure it contains queries triggered after this function runs.
context_extras
[
'sql_queries'
]
=
lazy
(
lambda
:
connection
.
queries
,
list
)
context_extras
[
'sql_queries'
]
=
lazy
(
lambda
:
list
(
itertools
.
chain
(
*
[
connections
[
x
]
.
queries
for
x
in
connections
])),
list
)
return
context_extras
return
context_extras
...
...
docs/ref/templates/api.txt
Dosyayı görüntüle @
03e1cc93
...
@@ -699,8 +699,13 @@ the request's IP address (``request.META['REMOTE_ADDR']``) is in the
...
@@ -699,8 +699,13 @@ the request's IP address (``request.META['REMOTE_ADDR']``) is in the
you're in :setting:`DEBUG` mode.
you're in :setting:`DEBUG` mode.
* ``sql_queries`` -- A list of ``{'sql': ..., 'time': ...}`` dictionaries,
* ``sql_queries`` -- A list of ``{'sql': ..., 'time': ...}`` dictionaries,
representing every SQL query that has happened so far during the request
representing every SQL query that has happened so far during the request
and how long it took. The list is in order by query and lazily generated
and how long it took. The list is in order by database alias and then by
on access.
query. It's lazily generated on access.
.. versionchanged:: 1.10
In older versions, only the queries for the default database alias were
included.
``django.template.context_processors.i18n``
``django.template.context_processors.i18n``
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
...
...
docs/releases/1.10.txt
Dosyayı görüntüle @
03e1cc93
...
@@ -414,6 +414,9 @@ Templates
...
@@ -414,6 +414,9 @@ Templates
* Allowed :tfilter:`dictsort` to order a list of lists by an element at a
* Allowed :tfilter:`dictsort` to order a list of lists by an element at a
specified index.
specified index.
* The :func:`~django.template.context_processors.debug` context processor
contains queries for all database aliases instead of only the default alias.
Tests
Tests
~~~~~
~~~~~
...
...
tests/context_processors/templates/context_processors/debug.html
Dosyayı görüntüle @
03e1cc93
...
@@ -12,4 +12,8 @@ Second query list: {{ sql_queries|length }}
...
@@ -12,4 +12,8 @@ Second query list: {{ sql_queries|length }}
Third query list: {{ sql_queries|length }}
Third query list: {{ sql_queries|length }}
{% for obj in other_debug_objects.all %}{{ obj }}{% endfor %}
Fourth query list: {{ sql_queries|length }}
{% endif %}
{% endif %}
tests/context_processors/tests.py
Dosyayı görüntüle @
03e1cc93
...
@@ -87,3 +87,5 @@ class DebugContextProcessorTests(TestCase):
...
@@ -87,3 +87,5 @@ class DebugContextProcessorTests(TestCase):
self
.
assertContains
(
response
,
'Second query list: 1'
)
self
.
assertContains
(
response
,
'Second query list: 1'
)
# Check we have not actually memoized connection.queries
# Check we have not actually memoized connection.queries
self
.
assertContains
(
response
,
'Third query list: 2'
)
self
.
assertContains
(
response
,
'Third query list: 2'
)
# Check queries for DB connection 'other'
self
.
assertContains
(
response
,
'Fourth query list: 3'
)
tests/context_processors/views.py
Dosyayı görüntüle @
03e1cc93
...
@@ -8,5 +8,8 @@ def request_processor(request):
...
@@ -8,5 +8,8 @@ def request_processor(request):
def
debug_processor
(
request
):
def
debug_processor
(
request
):
context
=
{
'debug_objects'
:
DebugObject
.
objects
}
context
=
{
'debug_objects'
:
DebugObject
.
objects
,
'other_debug_objects'
:
DebugObject
.
objects
.
using
(
'other'
),
}
return
render
(
request
,
'context_processors/debug.html'
,
context
)
return
render
(
request
,
'context_processors/debug.html'
,
context
)
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