Browse files

Added 'Loader types' section to docs/templates_python.txt

git-svn-id: bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
1 parent 57b4f23 commit 3df39deede8eba5a005ae8c487cd6320b04dc83c @adrianholovaty adrianholovaty committed Oct 17, 2005
Showing with 47 additions and 2 deletions.
  1. +47 −2 docs/templates_python.txt
@@ -287,8 +287,12 @@ Generally, you'll store templates in files on your filesystem rather than using
the low-level ``Template`` API yourself. Save templates in a file with an
".html" extension in a directory specified as a **template directory**.
-(The ".html" extension is just a required convention. It doesn't mean templates
-can only contain HTML. They can contain whatever textual content you want.)
+If you don't like the requirement that templates have an ".html" extension,
+change your ``TEMPLATE_FILE_EXTENSION`` setting. It's set to ``".html"`` by
+Also, the .html extension doesn't mean templates can contain only HTML. They
+can contain whatever textual content you want.
@@ -355,6 +359,47 @@ To load a template that's within a subdirectory, just use a slash, like so::
+Loader types
+By default, Django uses a filesystem-based template loader, but Django comes
+with a few other template loaders. They're disabled by default, but you can
+activate them by editing your ``TEMPLATE_LOADERS`` setting.
+``TEMPLATE_LOADERS`` should be a tuple of strings, where each string represents
+a template loader. Here are the built-in template loaders:
+ Loads templates from the filesystem, according to ``TEMPLATE_DIRS``.
+ Loads templates from Django apps on the filesystem. For each app in
+ ``INSTALLED_APPS``, the loader looks for a ``templates`` subdirectory. If
+ the directory exists, Django looks for templates in there.
+ This means you can store templates with your individual apps. This also
+ makes it easy to distribute Django apps with default templates.
+ For example, for this setting::
+ INSTALLED_APPS = ('myproject.polls', '')
+ ...then ``get_template("foo")`` will look for templates in these
+ directories, in this order:
+ * ``/path/to/myproject/polls/templates/foo.html``
+ * ``/path/to/myproject/music/templates/music.html``
+ Note that the loader performs an optimization when it is first imported:
+ It caches a list of which ``INSTALLED_APPS`` packages have a ``templates``
+ subdirectory.
+ Just like ``app_directories`` above, but it loads templates from Python
+ eggs rather than from the filesystem.
+Django uses the template loaders in order according to the ``TEMPLATE_LOADERS``
+setting. It uses each loader until a loader finds a match.
Extending the template system

0 comments on commit 3df39de

Please sign in to comment.