Package: django-vest
Extension for default template system for making inheritance more flexible. Adding some kind of themes.UsageImagine you have several sites on different hosts. They differ by visually and small functional.django-vestthis is a way to use one code base for this situation.He allowing to split templates onthemes- one per site. We also have extended inheritance between themes - we haveDEFAULT_THEMEand we can override each template inCURRENT_THEME. Exmaple:{% extends 'DEFAULT_THEME/index.html' %}
{% block page_title %}Dark theme{% endblock %}django-vesthave some tools for logic splitting according byCURRENT_THEMEin views. Assume we have someformclass who is different in each theme. Then our code may looks like:# forms.pyfromdjango_vest.decoratorsimportthemeble@themeble(name='Form',themes=('dark_theme',))classDarkThemeForm(object):''' Some kind of logic/fields for dark_theme form
    '''name='DarkThemeForm'@themeble(name='Form')classDefaultForm(object):''' Default logic/fields for all themes
    '''name='Default form'# views.pyfrom.formsimportFormIn example bellowFormclass will be alias for DarkThemeForm ifsettings.CURRENT_THEME == 'dark_theme'otherwise it isDefaultForm.If you want restricting access to views according byCURRENT_THEMEjust useonly_fordecorator:# views.pyfromdjango.httpimportHttp404fromdjango.views.generic.baseimportTemplateViewfromdjango_vestimportonly_for@only_for('black_theme')defmy_view(request):...# Redirect for special pagedark_theme_page=only_for('dark_theme',redirect_to='restict_access')(TemplateView.as_view(template_name='dark_theme_page.html'))# Raise Http404 when user trying to open page with invalid themedark_theme_page_not_found=\only_for('dark_theme',raise_error=Http404)(TemplateView.as_view(template_name='dark_theme_page.html'))Extends for default templatesVersion 0.1.3 has a new template loaderdjango_vest.templates_loaders.AppsLoaderand new keywordDJANGO_ORIGIN.Now we can override default django admin template without copy past of full origin file.Example:File:templates/main_theme/admin/change_list.html{% extends "DJANGO_ORIGIN/admin/change_list.html" %}
{% load i18n admin_urls admin_static admin_list %}

{% block breadcrumbs %}<div>Template has been overridden</div>{{ block.super }}
{% endblock %}Installation$pipinstalldjango_vestAnd add next setting options to yoursettings.py:TEMPLATE_LOADERS=('django_vest.templates_loaders.Loader','django_vest.templates_loaders.AppsLoader',)DEFAULT_THEME='main_theme'# Unique for each hostCURRENT_THEME='dark_theme'Or you can set os environment:exportDJANGO_VEST_CURRENT_THEME=dark_themeAlso you can specify list of backends for getting settings. Default is:VEST_SETTINGS_BACKENDS_LIST=('django_vest.config.backends.simple','django_vest.config.backends.env')django_vest.config.backends.simple - getting settings about theme from project`s settings file.django_vest.config.backends.env - from os enviromThen you need to update structure of your templates like this:exampleproject/templates/|-dark_theme|-index.html|-main_theme|-index.htmlIMPORTANT: theme folder must ends with_themesuffix (example: my_super_mega_theme)Other config backends (Experimental)Django-vest have are several other backends like:django_vest.config.backends.database. If you have some singleton model for store settings of your site you can usedjango_vest.fields.VestFieldfor storing information ofCURRENT_THEMEin database.For activating this feature you must do next steps:Adddjango_vest.fields.VestFieldto you settings model and migrate.Adddjango_vest.config.backends.databasebackend to top of VEST_SETTINGS_BACKENDS_LIST setting. Example:VEST_SETTINGS_BACKENDS_LIST=('django_vest.config.backends.database','django_vest.config.backends.simple','django_vest.config.backends.env',)ContributingFork thedjango-vestrepo on GitHub.Clone your fork locally:$gitclonegit@github.com:your_name_here/django-vest.gitInstall your local copy into a virtualenv. Assuming you have virtualenvwrapper installed, this is how you set up your fork for local development:$mkvirtualenvdjango-vest$cddjango-vest/$pythonsetup.pydevelopCreate a branch for local development:$gitcheckout-bname-of-your-bugfix-or-featureNowyoucanmakeyourchangeslocally.When you’re done making changes, check that your changes pass the tests, including testing other Python versions with tox:$maketest-allCommit your changes and push your branch to GitHub:$gitadd.$gitcommit-m"Your detailed description of your changes."$gitpushoriginname-of-your-bugfix-or-featureSubmit a pull request through the GitHub website.Licence & AuthorsThe MIT License (MIT)Copyright (c) 2015Vladimir Savin.