Skip to main content

Extension for default template system for making inheritance more flexible. Adding some kind of themes.

Project description

Latest PyPI version

Extension for default template system for making inheritance more flexible. Adding some kind of themes.

Usage

Imagine you have several sites on different hosts. They differ by visually and small functional. django-vest this is a way to use one code base for this situation.

He allowing to split templates on themes - one per site. We also have extended inheritance between themes - we have DEFAULT_THEME and we can override each template in CURRENT_THEME. Exmaple:

{% extends 'DEFAULT_THEME/index.html' %}
{% block page_title %}Dark theme{% endblock %}

django-vest have some tools for logic splitting according by CURRENT_THEME in views. Assume we have some form class who is different in each theme. Then our code may looks like:

# forms.py
from django_vest.decorators import themeble

@themeble(name='Form', themes=('dark_theme',))
class DarkThemeForm(object):
    ''' Some kind of logic/fields for dark_theme form
    '''
    name = 'DarkThemeForm'


@themeble(name='Form')
class DefaultForm(object):
    ''' Default logic/fields for all themes
    '''
    name = 'Default form'


# views.py
from .forms import Form

In example bellow Form class will be alias for DarkThemeForm if settings.CURRENT_THEME == 'dark_theme' otherwise it is DefaultForm.

Installation

Just type: pip install django_vest

Licence

The MIT License (MIT)

Copyright (c) 2015 Vladimir Savin

Authors

django-vest was written by Vladimir Savin.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django-vest-0.1.0.tar.gz (4.8 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page