template.loader.select_template()

select_template(template_name_list, using=None) [source] select_template() is just like get_template(), except it takes a list of template names. It tries each name in order and returns the first template that exists. If loading a template fails, the following two exceptions, defined in django.template, may be raised:

template.loaders.app_directories.Loader

class app_directories.Loader 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', 'myproject.music'] ...then get_template('foo.html') will look for foo

template.loaders.base.Loader

class Loader [source] Loads templates from a given source, such as the filesystem or a database. get_template_sources(template_name) [source] A method that takes a template_name and yields Origin instances for each possible source. For example, the filesystem loader may receive 'index.html' as a template_name argument. This method would yield origins for the full path of index.html as it appears in each template directory the loader looks at. The method doesn’t need to verify that the tem

template.loaders.base.Loader.get_contents()

get_contents(origin) Returns the contents for a template given a Origin instance. This is where a filesystem loader would read contents from the filesystem, or a database loader would read from the database. If a matching template doesn’t exist, this should raise a TemplateDoesNotExist error.

template.loaders.base.Loader.get_template()

get_template(template_name, skip=None) [source] Returns a Template object for a given template_name by looping through results from get_template_sources() and calling get_contents(). This returns the first matching template. If no template is found, TemplateDoesNotExist is raised. The optional skip argument is a list of origins to ignore when extending templates. This allow templates to extend other templates of the same name. It also used to avoid recursion errors. In general, it is enough

template.loaders.base.Loader.get_template_sources()

get_template_sources(template_name) [source] A method that takes a template_name and yields Origin instances for each possible source. For example, the filesystem loader may receive 'index.html' as a template_name argument. This method would yield origins for the full path of index.html as it appears in each template directory the loader looks at. The method doesn’t need to verify that the template exists at a given path, but it should ensure the path is valid. For instance, the filesystem l

template.loaders.base.Loader.load_template()

load_template(template_name, template_dirs=None) [source] Returns a tuple of (template, template_origin), where template is a Template object and template_origin is a string identifying the template source. A filesystem-based loader may return the full path to the file as the template_origin, for example. Deprecated since version 1.9: Custom loaders should use get_template() and get_contents() instead.

template.loaders.base.Loader.load_template_source()

load_template_source(template_name, template_dirs=None) [source] Returns a tuple of (template_string, template_origin), where template_string is a string containing the template contents, and template_origin is a string identifying the template source. A filesystem-based loader may return the full path to the file as the template_origin, for example. template_dirs is an optional argument used to control which directories the loader will search. This method is called automatically by load_tem

template.loaders.cached.Loader

class cached.Loader By default, the templating system will read and compile your templates every time they need to be rendered. While the Django templating system is quite fast, the overhead from reading and compiling templates can add up. The cached template loader is a class-based loader that you configure with a list of other loaders that it should wrap. The wrapped loaders are used to locate unknown templates when they are first encountered. The cached loader then stores the compiled Tem

template.loaders.eggs.Loader

class eggs.Loader Deprecated since version 1.9: Distributing applications as eggs is not recommended. Just like app_directories above, but it loads templates from Python eggs rather than from the filesystem. This loader is disabled by default. django.template.loaders.cached.Loader