Segelzwerg / django-dynamic-theme

This enables the administrator of a django website to change the theme on the fly.
MIT License
2 stars 2 forks source link

PyPI - Python Version GitHub Release

Documentation Status codecov

Django Dynamic Theme

This allows an administrator of a django website to change the theme on the fly.

Installation

pip install django-dynamic-theme

Quickstart

  1. Add the following settings::
INSTALLED_APPS = [
  ...,
  "django_dynamic_theme",
  "compressor",
]
...
# Default setting but you can set it to some other path.
STATIC_URL = "static/"
STATIC_ROOT = "static"
STATICFILES_FINDERS = [
    ...,
    "compressor.finders.CompressorFinder",
]
COMPRESS_PRECOMPILERS = (("text/x-scss", "django_libsass.SassCompiler"),)
MIDDLEWARE = [
    ...,
    "django_dynamic_theme.middleware.MissingThemeHandleMiddleware",
]
TEMPLATES = {
  "OPTIONS": {
    "context_processors": [
      ...,
      "django_dynamic_theme-context_processor.theme",
    ]
  }
}
  1. Run python manage.py migrate

  2. Assuming you have base.html add this to it before the <body> tag:

    <html>
    ...
    {% load compress %}
    {% load static %}
    {% compress css %}
    <link type="text/x-scss" rel="stylesheet" href="https://github.com/Segelzwerg/django-dynamic-theme/blob/main/{% static theme_file %}" />
    ...
    </html>
  3. Visit http://127.0.0.1:8000/admin/django_dynamic_theme/ to start customizing your theme.