.. _usage:

Usage
=====

Follow the steps below to use the django-userthemes application in your Django
project:

1. edit your Django project settings file:

 * add ``userthemes`` to the ``INSTALLED_APPS`` setting

 * add ``userthemes.loader.load_template_source`` to ``TEMPLATE_LOADERS``

 * add ``userthemes.middleware.UserThemesMiddleware`` to ``MIDDLEWARE_CLASSES``

.. note::

    If you got AttributeError talking about WSGIRequest, it's probably because
    middlewares loading order causes problem.
    It seems that with a basic project this order works well::
    
        'django.contrib.sessions.middleware.SessionMiddleware',
        'django.contrib.auth.middleware.AuthenticationMiddleware',
        'django.middleware.common.CommonMiddleware'
        'userthemes.middleware.UserThemesMiddleware',


2. Under your template dir, which by default is ``TEMPLATE_DIRS[0]``, create a ``themes`` directory to store your themes.
Check the :ref:`templates page <templatesandstatic>` for information on templates organisation and static content management.


3. To enable users to change their theme preference, add to your URLConf file
something like this::

    (r'^userthemes/', include('userthemes.urls')),

and create ``userthemes/edit_usertheme.html`` and ``userthemes/create_usertheme.html`` templates. 
    
4. Launch ``python manage.py syncdb``


.. note::

    You must use the '/static/' url path to handle your static content or change the default :ref:`configuration <configuration>`.

