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
15b711b5
Kaydet (Commit)
15b711b5
authored
Şub 15, 2015
tarafından
Aymeric Augustin
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Deprecated TEMPLATE_DEBUG setting.
üst
9fbd302f
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
72 additions
and
48 deletions
+72
-48
settings.py
django/conf/project_template/project_name/settings.py
+0
-2
django.py
django/template/backends/django.py
+1
-1
defaulttags.py
django/template/defaulttags.py
+2
-2
utils.py
django/template/utils.py
+1
-0
signals.py
django/test/signals.py
+1
-0
custom-template-tags.txt
docs/howto/custom-template-tags.txt
+3
-4
deprecation.txt
docs/internals/deprecation.txt
+1
-0
settings.txt
docs/ref/settings.txt
+5
-0
api.txt
docs/ref/templates/api.txt
+1
-1
upgrading.txt
docs/ref/templates/upgrading.txt
+7
-3
1.4.txt
docs/releases/1.4.txt
+2
-2
1.7.txt
docs/releases/1.7.txt
+1
-1
1.8.txt
docs/releases/1.8.txt
+1
-0
settings.txt
docs/topics/settings.txt
+1
-1
templates.txt
docs/topics/templates.txt
+1
-3
tests.py
tests/generic_inline_admin/tests.py
+6
-4
test_nodelist.py
tests/template_tests/test_nodelist.py
+1
-1
test_parser.py
tests/template_tests/test_parser.py
+1
-1
tests.py
tests/template_tests/tests.py
+35
-20
test_debug.py
tests/view_tests/tests/test_debug.py
+1
-2
No files found.
django/conf/project_template/project_name/settings.py
Dosyayı görüntüle @
15b711b5
...
...
@@ -25,8 +25,6 @@ SECRET_KEY = '{{ secret_key }}'
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG
=
True
TEMPLATE_DEBUG
=
True
ALLOWED_HOSTS
=
[]
...
...
django/template/backends/django.py
Dosyayı görüntüle @
15b711b5
...
...
@@ -18,7 +18,7 @@ class DjangoTemplates(BaseEngine):
def
__init__
(
self
,
params
):
params
=
params
.
copy
()
options
=
params
.
pop
(
'OPTIONS'
)
.
copy
()
options
.
setdefault
(
'debug'
,
settings
.
TEMPLATE_
DEBUG
)
options
.
setdefault
(
'debug'
,
settings
.
DEBUG
)
options
.
setdefault
(
'file_charset'
,
settings
.
FILE_CHARSET
)
super
(
DjangoTemplates
,
self
)
.
__init__
(
params
)
self
.
engine
=
Engine
(
self
.
dirs
,
self
.
app_dirs
,
**
options
)
...
...
django/template/defaulttags.py
Dosyayı görüntüle @
15b711b5
...
...
@@ -209,8 +209,8 @@ class ForNode(Node):
context
.
update
(
unpacked_vars
)
else
:
context
[
self
.
loopvars
[
0
]]
=
item
# In
TEMPLATE_DEBUG mode provide source of the node which
#
actually raised
the exception
# In
debug mode provide the source of the node which raised
# the exception
if
context
.
engine
.
debug
:
for
node
in
self
.
nodelist_loop
:
try
:
...
...
django/template/utils.py
Dosyayı görüntüle @
15b711b5
...
...
@@ -42,6 +42,7 @@ class EngineHandler(object):
'OPTIONS'
:
{
'allowed_include_roots'
:
settings
.
ALLOWED_INCLUDE_ROOTS
,
'context_processors'
:
settings
.
TEMPLATE_CONTEXT_PROCESSORS
,
'debug'
:
settings
.
TEMPLATE_DEBUG
,
'loaders'
:
settings
.
TEMPLATE_LOADERS
,
'string_if_invalid'
:
settings
.
TEMPLATE_STRING_IF_INVALID
,
},
...
...
django/test/signals.py
Dosyayı görüntüle @
15b711b5
...
...
@@ -93,6 +93,7 @@ def reset_template_engines(**kwargs):
'TEMPLATE_DEBUG'
,
'TEMPLATE_LOADERS'
,
'TEMPLATE_STRING_IF_INVALID'
,
'DEBUG'
,
'FILE_CHARSET'
,
'INSTALLED_APPS'
,
}:
...
...
docs/howto/custom-template-tags.txt
Dosyayı görüntüle @
15b711b5
...
...
@@ -756,10 +756,9 @@ Notes:
* The ``render()`` method is where the work actually happens.
* ``render()`` should generally fail silently, particularly in a production
environment where :setting:`DEBUG` and :setting:`TEMPLATE_DEBUG` are
``False``. In some cases however, particularly if :setting:`TEMPLATE_DEBUG` is
``True``, this method may raise an exception to make debugging easier. For
example, several core tags raise ``django.template.TemplateSyntaxError``
environment. In some cases however, particularly if ``context.engine.debug``
is ``True``, this method may raise an exception to make debugging easier.
For example, several core tags raise ``django.template.TemplateSyntaxError``
if they receive the wrong number or type of arguments.
Ultimately, this decoupling of compilation and rendering results in an
...
...
docs/internals/deprecation.txt
Dosyayı görüntüle @
15b711b5
...
...
@@ -116,6 +116,7 @@ details on these changes.
* ``ALLOWED_INCLUDE_ROOTS``
* ``TEMPLATE_CONTEXT_PROCESSORS``
* ``TEMPLATE_DEBUG``
* ``TEMPLATE_DIRS``
* ``TEMPLATE_LOADERS``
* ``TEMPLATE_STRING_IF_INVALID``
...
...
docs/ref/settings.txt
Dosyayı görüntüle @
15b711b5
...
...
@@ -2250,6 +2250,11 @@ TEMPLATE_DEBUG
Default: ``False``
.. deprecated:: 1.8
Set the ``'debug'`` option in the :setting:`OPTIONS <TEMPLATES-OPTIONS>`
of a ``DjangoTemplates`` backend instead.
A boolean that turns on/off template debug mode. If this is ``True``, the fancy
error page will display a detailed report for any exception raised during
template rendering. This report contains the relevant snippet of the template,
...
...
docs/ref/templates/api.txt
Dosyayı görüntüle @
15b711b5
...
...
@@ -936,7 +936,7 @@ Template origin
When an :class:`~django.template.Engine` is initialized with ``debug=True``,
its templates have an ``origin`` attribute depending on the source they are
loaded from. For engines initialized by Django, ``debug`` defaults to the
value of :setting:`
TEMPLATE_
DEBUG`.
value of :setting:`DEBUG`.
.. class:: loader.LoaderOrigin
...
...
docs/ref/templates/upgrading.txt
Dosyayı görüntüle @
15b711b5
...
...
@@ -10,7 +10,7 @@ The :setting:`TEMPLATES` settings
=================================
A new setting was introduced in Django 1.8: :setting:`TEMPLATES`. All existing
template-related settings
except :setting:`TEMPLATE_DEBUG`
were deprecated.
template-related settings were deprecated.
During the deprecation period, Django will create a backwards-compatible
:setting:`TEMPLATES` based on the ``TEMPLATE_*`` settings if you don't define
...
...
@@ -85,9 +85,13 @@ If your settings module defines ``ALLOWED_INCLUDE_ROOTS`` or
``'allowed_include_roots'`` and ``'string_if_invalid'`` keys in the
``'OPTIONS'`` dictionary.
If it sets ``TEMPLATE_DEBUG`` to a value that differs from :setting:`DEBUG`,
include that value under the ``'debug'`` key in ``'OPTIONS'``.
Once you have defined :setting:`TEMPLATES`, you can safely remove
``ALLOWED_INCLUDE_ROOTS``, ``TEMPLATE_CONTEXT_PROCESSORS``, ``TEMPLATE_DIRS``,
``TEMPLATE_LOADERS``, and ``TEMPLATE_STRING_IF_INVALID``.
``ALLOWED_INCLUDE_ROOTS``, ``TEMPLATE_CONTEXT_PROCESSORS``,
``TEMPLATE_DEBUG``, ``TEMPLATE_DIRS``, ``TEMPLATE_LOADERS``, and
``TEMPLATE_STRING_IF_INVALID``.
If you are overriding some of these settings in tests, you should override the
entire :setting:`TEMPLATES` setting instead.
...
...
docs/releases/1.4.txt
Dosyayı görüntüle @
15b711b5
...
...
@@ -437,7 +437,7 @@ For example:
No wrapping of exceptions in ``TEMPLATE_DEBUG`` mode
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In previous versions of Django, whenever the
:setting:`TEMPLATE_DEBUG
` setting
In previous versions of Django, whenever the
``TEMPLATE_DEBUG`
` setting
was ``True``, any exception raised during template rendering (even exceptions
unrelated to template syntax) were wrapped in ``TemplateSyntaxError`` and
re-raised. This was done in order to provide detailed template source location
...
...
@@ -446,7 +446,7 @@ information in the debug 500 page.
In Django 1.4, exceptions are no longer wrapped. Instead, the original
exception is annotated with the source information. This means that catching
exceptions from template rendering is now consistent regardless of the value of
:setting:`TEMPLATE_DEBUG
`, and there's no need to catch and unwrap
``TEMPLATE_DEBUG`
`, and there's no need to catch and unwrap
``TemplateSyntaxError`` in order to catch other errors.
``truncatechars`` template filter
...
...
docs/releases/1.7.txt
Dosyayı görüntüle @
15b711b5
...
...
@@ -845,7 +845,7 @@ Templates
* It is now possible to :ttag:`include` templates recursively.
* Template objects now have an origin attribute set when
:setting:`TEMPLATE_DEBUG
` is ``True``. This allows template origins to be
``TEMPLATE_DEBUG`
` is ``True``. This allows template origins to be
inspected and logged outside of the ``django.template`` infrastructure.
* ``TypeError`` exceptions are no longer silenced when raised during the
...
...
docs/releases/1.8.txt
Dosyayı görüntüle @
15b711b5
...
...
@@ -1263,6 +1263,7 @@ are deprecated in favor of :setting:`TEMPLATES`:
* ``ALLOWED_INCLUDE_ROOTS``
* ``TEMPLATE_CONTEXT_PROCESSORS``
* ``TEMPLATE_DEBUG``
* ``TEMPLATE_DIRS``
* ``TEMPLATE_LOADERS``
* ``TEMPLATE_STRING_IF_INVALID``
...
...
docs/topics/settings.txt
Dosyayı görüntüle @
15b711b5
...
...
@@ -188,7 +188,7 @@ Example::
from django.conf import settings
settings.configure(DEBUG=True
, TEMPLATE_DEBUG=True
)
settings.configure(DEBUG=True)
Pass ``configure()`` as many keyword arguments as you'd like, with each keyword
argument representing a setting and its value. Each argument name should be all
...
...
docs/topics/templates.txt
Dosyayı görüntüle @
15b711b5
...
...
@@ -356,9 +356,7 @@ applications. This generic name was kept for backwards-compatibility.
exception raised during template rendering. This report contains the
relevant snippet of the template with the appropriate line highlighted.
It defaults to the value of the :setting:`TEMPLATE_DEBUG` setting. The
setting is convenient for toggling template debug mode globally rather than
on a per-engine basis.
It defaults to the value of the :setting:`DEBUG` setting.
* ``'loaders'``: a list of dotted Python paths to template loader classes.
Each ``Loader`` class knows how to import templates from a particular
...
...
tests/generic_inline_admin/tests.py
Dosyayı görüntüle @
15b711b5
...
...
@@ -15,11 +15,13 @@ from .admin import MediaInline, MediaPermanentInline, site as admin_site
from
.models
import
Category
,
Episode
,
EpisodePermanent
,
Media
# Set
TEMPLATE_
DEBUG to True to ensure {% include %} will raise exceptions.
# Set DEBUG to True to ensure {% include %} will raise exceptions.
# That is how inlines are rendered and #9498 will bubble up if it is an issue.
@override_settings
(
PASSWORD_HASHERS
=
[
'django.contrib.auth.hashers.SHA1PasswordHasher'
],
TEMPLATE_DEBUG
=
True
,
ROOT_URLCONF
=
"generic_inline_admin.urls"
)
@override_settings
(
DEBUG
=
True
,
PASSWORD_HASHERS
=
[
'django.contrib.auth.hashers.SHA1PasswordHasher'
],
ROOT_URLCONF
=
"generic_inline_admin.urls"
,
)
class
GenericAdminViewTest
(
TestCase
):
fixtures
=
[
'users.xml'
]
...
...
tests/template_tests/test_nodelist.py
Dosyayı görüntüle @
15b711b5
...
...
@@ -33,7 +33,7 @@ class ErrorIndexTest(TestCase):
Checks whether index of error is calculated correctly in
template debugger in for loops. Refs ticket #5831
"""
@override_settings
(
DEBUG
=
True
,
TEMPLATE_DEBUG
=
True
)
@override_settings
(
DEBUG
=
True
)
def
test_correct_exception_index
(
self
):
tests
=
[
(
'{
%
load bad_tag
%
}{
%
for i in range
%
}{
%
badsimpletag
%
}{
%
endfor
%
}'
,
(
38
,
56
)),
...
...
tests/template_tests/test_parser.py
Dosyayı görüntüle @
15b711b5
...
...
@@ -89,7 +89,7 @@ class ParserTests(TestCase):
with
six
.
assertRaisesRegex
(
self
,
TypeError
,
"Variable must be a string or number, got <(class|type) 'dict'>"
):
Variable
({})
@override_settings
(
DEBUG
=
True
,
TEMPLATE_DEBUG
=
True
)
@override_settings
(
DEBUG
=
True
)
def
test_compile_filter_error
(
self
):
# regression test for #19819
msg
=
"Could not parse the remainder: '@bar' from 'foo@bar'"
...
...
tests/template_tests/tests.py
Dosyayı görüntüle @
15b711b5
...
...
@@ -85,10 +85,12 @@ class TemplateLoaderTests(SimpleTestCase):
@override_settings
(
TEMPLATES
=
[{
'BACKEND'
:
'django.template.backends.django.DjangoTemplates'
,
'DIRS'
:
[
TEMPLATES_DIR
],
'OPTIONS'
:
{
# Turn DEBUG on, so that the origin file name will be kept with
# the compiled templates.
'debug'
:
True
,
}
}])
# Turn TEMPLATE_DEBUG on, so that the origin file name will be kept with
# the compiled templates.
@override_settings
(
TEMPLATE_DEBUG
=
True
)
def
test_loader_debug_origin
(
self
):
load_name
=
'login.html'
...
...
@@ -104,6 +106,7 @@ class TemplateLoaderTests(SimpleTestCase):
'BACKEND'
:
'django.template.backends.django.DjangoTemplates'
,
'DIRS'
:
[
TEMPLATES_DIR
],
'OPTIONS'
:
{
'debug'
:
True
,
'loaders'
:
[
(
'django.template.loaders.cached.Loader'
,
[
'django.template.loaders.filesystem.Loader'
,
...
...
@@ -111,7 +114,6 @@ class TemplateLoaderTests(SimpleTestCase):
],
},
}])
@override_settings
(
TEMPLATE_DEBUG
=
True
)
def
test_cached_loader_debug_origin
(
self
):
load_name
=
'login.html'
...
...
@@ -126,12 +128,12 @@ class TemplateLoaderTests(SimpleTestCase):
self
.
assertTrue
(
template_name
.
endswith
(
load_name
),
'Cached template loaded through cached loader has incorrect name for debug page:
%
s'
%
template_name
)
@override_settings
(
TEMPLATE_
DEBUG
=
True
)
@override_settings
(
DEBUG
=
True
)
def
test_loader_origin
(
self
):
template
=
loader
.
get_template
(
'login.html'
)
self
.
assertEqual
(
template
.
origin
.
loadname
,
'login.html'
)
@override_settings
(
TEMPLATE_
DEBUG
=
True
)
@override_settings
(
DEBUG
=
True
)
def
test_string_origin
(
self
):
template
=
Template
(
'string template'
)
self
.
assertEqual
(
template
.
origin
.
source
,
'string template'
)
...
...
@@ -140,15 +142,17 @@ class TemplateLoaderTests(SimpleTestCase):
template
=
loader
.
get_template
(
'login.html'
)
self
.
assertEqual
(
template
.
origin
,
None
)
# TEMPLATE_DEBUG must be true, otherwise the exception raised
# during {% include %} processing will be suppressed.
@override_settings
(
TEMPLATE_DEBUG
=
True
)
# Test the base loader class via the app loader. load_template
# from base is used by all shipped loaders excepting cached,
# which has its own test.
@override_settings
(
TEMPLATES
=
[{
'BACKEND'
:
'django.template.backends.django.DjangoTemplates'
,
'APP_DIRS'
:
True
,
'OPTIONS'
:
{
# Enable debug, otherwise the exception raised during
# {% include %} processing will be suppressed.
'debug'
:
True
,
}
}])
def
test_include_missing_template
(
self
):
"""
...
...
@@ -164,15 +168,17 @@ class TemplateLoaderTests(SimpleTestCase):
self
.
assertEqual
(
e
.
args
[
0
],
'missing.html'
)
self
.
assertEqual
(
r
,
None
,
'Template rendering unexpectedly succeeded, produced: ->
%
r<-'
%
r
)
# TEMPLATE_DEBUG must be true, otherwise the exception raised
# during {% include %} processing will be suppressed.
@override_settings
(
TEMPLATE_DEBUG
=
True
)
# Test the base loader class via the app loader. load_template
# from base is used by all shipped loaders excepting cached,
# which has its own test.
@override_settings
(
TEMPLATES
=
[{
'BACKEND'
:
'django.template.backends.django.DjangoTemplates'
,
'APP_DIRS'
:
True
,
'OPTIONS'
:
{
# Enable debug, otherwise the exception raised during
# {% include %} processing will be suppressed.
'debug'
:
True
,
}
}])
def
test_extends_include_missing_baseloader
(
self
):
"""
...
...
@@ -193,6 +199,7 @@ class TemplateLoaderTests(SimpleTestCase):
@override_settings
(
TEMPLATES
=
[{
'BACKEND'
:
'django.template.backends.django.DjangoTemplates'
,
'OPTIONS'
:
{
'debug'
:
True
,
'loaders'
:
[
(
'django.template.loaders.cached.Loader'
,
[
'django.template.loaders.app_directories.Loader'
,
...
...
@@ -200,7 +207,6 @@ class TemplateLoaderTests(SimpleTestCase):
],
},
}])
@override_settings
(
TEMPLATE_DEBUG
=
True
)
def
test_extends_include_missing_cachedloader
(
self
):
"""
Same as test_extends_include_missing_baseloader, only tests
...
...
@@ -235,19 +241,28 @@ class TemplateLoaderTests(SimpleTestCase):
output
=
outer_tmpl
.
render
(
ctx
)
self
.
assertEqual
(
output
,
'This worked!'
)
@override_settings
(
TEMPLATE_DEBUG
=
True
)
@override_settings
(
TEMPLATES
=
[{
'BACKEND'
:
'django.template.backends.django.DjangoTemplates'
,
'OPTIONS'
:
{
'debug'
:
True
,
},
}])
def
test_include_immediate_missing
(
self
):
"""
Regression test for #16417 -- {
%
include
%
} tag raises TemplateDoesNotExist at compile time if TEMPLATE_DEBUG is True
Test that an {
%
include
%
} tag with a literal string referencing a
template that does not exist does not raise an exception at parse
time.
time.
Regression test for #16417.
"""
tmpl
=
Template
(
'{
%
include "this_does_not_exist.html"
%
}'
)
self
.
assertIsInstance
(
tmpl
,
Template
)
@override_settings
(
TEMPLATE_DEBUG
=
True
)
@override_settings
(
TEMPLATES
=
[{
'BACKEND'
:
'django.template.backends.django.DjangoTemplates'
,
'APP_DIRS'
:
True
,
'OPTIONS'
:
{
'debug'
:
True
,
},
}])
def
test_include_recursive
(
self
):
comments
=
[
{
...
...
@@ -277,7 +292,7 @@ class TemplateRegressionTests(SimpleTestCase):
split
=
token
.
split_contents
()
self
.
assertEqual
(
split
,
[
"sometag"
,
'_("Page not found")'
,
'value|yesno:_("yes,no")'
])
@override_settings
(
SETTINGS_MODULE
=
None
,
TEMPLATE_
DEBUG
=
True
)
@override_settings
(
SETTINGS_MODULE
=
None
,
DEBUG
=
True
)
def
test_url_reverse_no_settings_module
(
self
):
# Regression test for #9005
t
=
Template
(
'{
%
url will_not_match
%
}'
)
...
...
@@ -307,7 +322,7 @@ class TemplateRegressionTests(SimpleTestCase):
self
.
assertGreater
(
depth
,
5
,
"The traceback context was lost when reraising the traceback. See #19827"
)
@override_settings
(
DEBUG
=
True
,
TEMPLATE_DEBUG
=
True
)
@override_settings
(
DEBUG
=
True
)
def
test_no_wrapped_exception
(
self
):
"""
The template system doesn't wrap exceptions, but annotates them.
...
...
tests/view_tests/tests/test_debug.py
Dosyayı görüntüle @
15b711b5
...
...
@@ -44,8 +44,7 @@ class CallableSettingWrapperTests(TestCase):
self
.
assertEqual
(
actual
,
"repr from the wrapped callable"
)
@override_settings
(
DEBUG
=
True
,
TEMPLATE_DEBUG
=
True
,
ROOT_URLCONF
=
"view_tests.urls"
)
@override_settings
(
DEBUG
=
True
,
ROOT_URLCONF
=
"view_tests.urls"
)
class
DebugViewTests
(
TestCase
):
def
test_files
(
self
):
...
...
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