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
92c5eeac
Kaydet (Commit)
92c5eeac
authored
Ara 13, 2016
tarafından
Tim Graham
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed #27598 -- Allowed specifying directories for a filesystem template loader.
Thanks Carl Meyer for review.
üst
7da37699
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
39 additions
and
1 deletion
+39
-1
filesystem.py
django/template/loaders/filesystem.py
+5
-1
api.txt
docs/ref/templates/api.txt
+20
-0
1.11.txt
docs/releases/1.11.txt
+3
-0
test_loaders.py
tests/template_tests/test_loaders.py
+11
-0
No files found.
django/template/loaders/filesystem.py
Dosyayı görüntüle @
92c5eeac
...
...
@@ -16,8 +16,12 @@ from .base import Loader as BaseLoader
class
Loader
(
BaseLoader
):
def
__init__
(
self
,
engine
,
dirs
=
None
):
super
(
Loader
,
self
)
.
__init__
(
engine
)
self
.
dirs
=
dirs
def
get_dirs
(
self
):
return
self
.
engine
.
dirs
return
self
.
dirs
if
self
.
dirs
is
not
None
else
self
.
engine
.
dirs
def
get_contents
(
self
,
origin
):
try
:
...
...
docs/ref/templates/api.txt
Dosyayı görüntüle @
92c5eeac
...
...
@@ -847,6 +847,26 @@ loaders that come with Django:
'DIRS': [os.path.join(BASE_DIR, 'templates')],
}]
You can also override ``'DIRS'`` and specify specific directories for a
particular filesystem loader::
TEMPLATES = [{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'OPTIONS': {
'loaders': [
(
'django.template.loaders.filesystem.Loader',
[os.path.join(BASE_DIR, 'templates')],
),
],
},
}]
.. versionchanged:: 1.11
The ability to specify directories for a particular filesystem loader
was added.
``django.template.loaders.app_directories.Loader``
.. class:: app_directories.Loader
...
...
docs/releases/1.11.txt
Dosyayı görüntüle @
92c5eeac
...
...
@@ -391,6 +391,9 @@ Templates
* Added a :ttag:`resetcycle` template tag to allow resetting the sequence of
the :ttag:`cycle` template tag.
* You can now specify specific directories for a particular
:class:`filesystem.Loader <django.template.loaders.filesystem.Loader>`.
Tests
~~~~~
...
...
tests/template_tests/test_loaders.py
Dosyayı görüntüle @
92c5eeac
...
...
@@ -312,6 +312,17 @@ class FileSystemLoaderTests(SimpleTestCase):
self
.
assertEqual
(
template
.
origin
.
loader
,
self
.
engine
.
template_loaders
[
0
])
self
.
assertEqual
(
template
.
origin
.
loader_name
,
'django.template.loaders.filesystem.Loader'
)
def
test_loaders_dirs
(
self
):
engine
=
Engine
(
loaders
=
[(
'django.template.loaders.filesystem.Loader'
,
[
TEMPLATE_DIR
])])
template
=
engine
.
get_template
(
'index.html'
)
self
.
assertEqual
(
template
.
origin
.
name
,
os
.
path
.
join
(
TEMPLATE_DIR
,
'index.html'
))
def
test_loaders_dirs_empty
(
self
):
"""An empty dirs list in loaders overrides top level dirs."""
engine
=
Engine
(
dirs
=
[
TEMPLATE_DIR
],
loaders
=
[(
'django.template.loaders.filesystem.Loader'
,
[])])
with
self
.
assertRaises
(
TemplateDoesNotExist
):
engine
.
get_template
(
'index.html'
)
@ignore_warnings
(
category
=
RemovedInDjango20Warning
)
def
test_load_template_source
(
self
):
loader
=
self
.
engine
.
template_loaders
[
0
]
...
...
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