.. _templatesandstatic:

Templates
=========

Django-userthemes will use its own configuration values to search for the
templates files Django needs, namely ``TEMPLATES_DIR``, ``THEMES_DIR`` and 
``DEFAULT_THEME``.

In ``TEMPLATES_DIR`` it will search for the ``THEMES_DIR`` directory which 
**must** exists.
In the ``THEMES_DIR`` it will search for directories for all the themes and in
particular ``DEFAULT_THEME`` which points to the default theme obviously.

So templates organisation needs to look like this::

    TEMPLATES_DIR/
                  THEMES_DIR/
                             DEFAULT_THEME/
                             secondtheme/
                             anotherone/


Static content
==============

To handle your static content (images, css files...) you must use the 
templatetag provided by the application.
Files must be situated under their specific theme and must be referenced in
the template file by something like this::

    {% load userthemes_tags %}

    <link rel='stylesheet' type='text/css' href='{{ "css/main.css"|usertheme_media_url }}'>

With the previous sentence the ``css/main.css`` will be converted to a relative
path indicating where the file is situated depending on the active theme and
the ``STATIC_URL`` configuration value.

If the active theme is secondtheme, the returned path will be::

    STATIC_URL/THEMES_DIR/secondtheme/css/main.css

so you webserver will only need to serve ``TEMPLATES_DIR`` directory under the ``STATIC_URL`` url.


.. seealso::
    The :ref:`configuration page <configuration>` indicates which configuration
    values exists, which are their default values and how to change it.


