Skip to main content

Django application, implement theming concept, flexible and configurable. Allow theming for host url.

Project description

https://pypip.in/v/django-theming/badge.svg?text=version&style=flat https://pypip.in/d/django-theming/badge.svg?style=flat https://pypip.in/py_versions/django-theming/badge.svg?style=flat https://pypip.in/status/django-theming/badge.svg?style=flat https://pypip.in/license/django-theming/badge.svg?style=flat

Django application, implement theming concept, flexible and configurable. Allow theming for host url.

Installation

You can install the most recent Django Theming version using pip:

pip install django-theming

Setup

NOTE: The following settings should be added to the project file settings.py.

  1. Add ‘theming’ to INSTALLED_APPS:

    INSTALLED_APPS += ( 'theming', )
  2. Add ‘theming.middleware.ThemingMiddleware’ to MIDDLEWARE_CLASSES:

    MIDDLEWARE_CLASSES += ( 'theming.middleware.ThemingMiddleware', )
  1. Add ‘theming.loaders.ThemeLoader’ to TEMPLATE_LOADERS:

    TEMPLATE_LOADERS += ( 'theming.loaders.ThemeLoader', )
  1. Declare THEME_ROOT and MEDIA_ROOT:

    BASE_DIR = os.path.dirname(os.path.dirname(__file__))
    
    THEME_ROOT = os.path.join(BASE_DIR, 'themes')
    MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
  2. Declare MEDIA_URL:

    MEDIA_URL = '/media/'
  3. Declare THEME_MEDIA_ROOT y THEME_MEDIA_URL:

    THEME_MEDIA_ROOT = os.path.join(MEDIA_ROOT, 'themes')
    THEME_MEDIA_URL = os.path.join(MEDIA_URL, 'themes')
  4. Declare host/theme config tuple THEME_CONFIG:

    THEME_CONFIG = (
        (r'^(.+\.)?dominio\.pe', 'default'),
        (r'^(.+\.)?test\.pe', 'test'),
    )

Usage

It should create a folder themes at the project with the following structure:

project_django/
| -- themes/
    | -- default/  ** theme name
        | -- templates/
        | -- media/
        |   | -- styles/
        |   | -- scripts/
        |   | -- images/
        | -- metadata.json

NOTE: We use media instead of static for independent assets by theme.

In the file metadata.json it should include information on the theme:

{
    "slug": "default",
    "name": "Default",
    "description": "Theme Default",
    "author": "Author",
    "version": "1.0"
}

You can use the template tag theme to refer to the theme assets as follows:

<link rel="stylesheet" href="{% theme 'styles/main.css' %}" />

NOTE: The tamplate tag theme will refer to the media/themes/<theme_name> folder, if not find the file in that path, it will search in static/

You can use the command collectthemes to copy all assets of the theme to the location media/:

python manage.py collectthemes

options:
- l, --link : Create a symbolic link to each file instead of copying.
- f, --force: Force to overwrite content.

Contributing

Development of django-theming happens at github: https://github.com/achavezu89/django-theming

Credits

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-theming-1.0.tar.gz (4.7 kB view details)

Uploaded Source

File details

Details for the file django-theming-1.0.tar.gz.

File metadata

  • Download URL: django-theming-1.0.tar.gz
  • Upload date:
  • Size: 4.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for django-theming-1.0.tar.gz
Algorithm Hash digest
SHA256 de563eb8d394acaa19d18fcad34e3f41a2e6dabb123591750c700cdd7967b54d
MD5 4f3d7c12a0e8eedfc4dc7b41f70c82ac
BLAKE2b-256 04ae2efb819c7635aadb19455b1a495ffba808bbcfb3dbefbe82c2ec99f8a3b1

See more details on using hashes here.

Supported by

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