Skip to main content

django-theme-academy

django-theme-academy provides the Academy theme for Django websites and applications. Academy provides the following features:

  • Built with Tabler, and Bootstrap 5
  • A fixed left sidebar with configurable logo
  • Breadcrumbs
  • A footer with contact information for your organiization
  • Includes django-wildewidgets support

Installation

django-theme-academy supports Python 3.7+, and Django 3+.

To install from PyPI:

pip install django-theme-academy

Update settings.py

Register the module in INSTALLED_APPS:

INSTALLED_APPS = [
    ...
    'academy_theme',
    ...
]

Add the custom template context processor:

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'OPTIONS': {
            ...
            'context_processors': [
                ...
                'academy_theme.context_processors.theme',
                ...
            ],
        },
    },
]

Optionally configure the theme specific settings. You don't need to define all of these, but instead only the ones you wish to override:

ACADEMY_THEME_SETTINGS = {
    # Header
    'APPLE_TOUCH_ICON': 'myapp/images/apple-touch-icon.png',
    'FAVICON_32': 'myapp/images/favicon-32x32.png',
    'FAVICON_16': 'myapp/images/favicon-16x16.png',
    'FAVICON': 'myapp/images/favicon.ico',
    'SITE_WEBMANIFEST': 'myapp/images/site.webmanifest',
    'LOGOUT_TITLE': 'Log out of this site',
    'LOGOUT_LINK': '/my/logout/link'

    # Footer
    'ORGANIZATION_LINK': 'https://myorg.com',
    'ORGANIZATION_NAME': 'Organization Name',
    'ORGANIZATION_ADDRESS': 'Organization Address',
    'COPYRIGHT_ORGANIZATION': 'Copyright Organization'
    'FOOTER_LINKS': []
}

Choose a base.hml

django-theme-academy ships with two different base templates:

  • academy_theme/base.html, for regular Django template development
  • academy_theme/base--wildewidgets.html, for django-wildewidgets based Django development

base.html

To use academy_theme/base.html, create your own base.html that extends it and overrides its blocks as needed. Example:

{% extends 'academy_theme/base.html' %}
{% load static academy_theme i18n %}

{% block title %}{% trans 'My App Title' %}{% endblock %}

{% block extra_css %}
  <link rel="stylesheet" href="{% static 'myapp/css/styles.css' %}">
{% endblock %}

{% block extra_header_js %}
  <script src="{% static 'myapp/js/app.js %}" ></script>
{% endblock %}

{% block menu %}
<nav class="navbar navbar-vertical navbar-expand-lg navbar-dark">
 <div class="container-lg ms-0">
    <a class="navbar-brand" href="#">
        <img src="{% static 'myapp/images/logo.png' %} alt="My App" width="100%">
    </a>
    <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContentV_9628" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
      <span class="navbar-toggler-icon"></span>
    </button>
    <div class="collapse navbar-collapse" id="navbarSupportedContent">
      <ul class="navbar-nav me-1">
       <li class="nav-item">
          <a class="nav-link" href="/">Home</a>
        </li>
      </ul>
    </div>
  </div>
</nav>
{% endblock %}

{% block breadcrumbs %}
  <ol class="breadcrumb">
    {% block breadcrumb-items %}
        {% breadcrumb 'Home' 'myapp:home' %}
    {% endblock %}
  </ol>
{% endblock %}

base-wildewidgets.html

If you don't need to add any Javascript or CSS, this can be used directly in your django-wildewidgets based views, like so:

from typing import List, Tuple, Type

from academy_theme.wildewidgets import AcademyThemeMainMenu
from django.templatetags.static import static
from wildewidgets import (
    BasicMenu,
    BreadcrumbBlock,
    CardWidget,
    MenuMixin,
    StandardWidgetMixin,
    WidgetListLayout
)

class MainMenu(AcademyThemeMainMenu):
    brand_image: str = static("myapp/images/logo.png")
    brand_text: str = "My App"
    items: List[Tuple[str, str]] = [
        ('Home', 'myapp:home'),
    ]


class BaseBreadcrumbs(BreadcrumbBlock):
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.add_breadcrumb('Home', reverse('myapp:home'))


class WildewidgetsView(
    MenuMixin,
    StandardWidgetMixin,
    TemplateView
):
    template_name: str = "academy_theme/base--wildewidgets.html"
    menu_class: Type[BasicMenu] = MainMenu
    menu_item: str = "Home"

    def get_content(self) -> WidgetListLayout:
        layout = WidgetListLayout("Wildewidgets Example")
        layout.add_widget(
            CardWidget(
                card_title='My Card',
                widget='Here is my card body',
            ),
            title='My Card',
            icon='info-square'
        )
        return layout

    def get_breadcrumbs(self) -> BreadcrumbBlock:
        breadcrumbs = BaseBreadcrumbs()
        breadcrumbs.add_breadcrumb('Wildewidgets')
        return breadcrumbs

If you do need to add Javascript or CSS, create your own base--wildewidgets.html that extends the acadmey_theme one and and overrides its blocks as needed. Example:

{% extends 'academy_theme/base--wildewidgets.html' %}
{% load static %}

{% block extra_css %}
  <link rel="stylesheet" href="{% static 'myapp/css/styles.css' %}">
{% endblock %}

{% block extra_header_js %}
  <script src="{% static 'myapp/js/app.js %}" ></script>
{% endblock %}

Metadata

Release files for django-theme-academy 0.3.13

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-theme-academy 0.3.13
File Size Uploaded Provenance
django_theme_academy-0.3.13.tar.gz 227.0 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for django-theme-academy 0.3.13
File Interpreter ABI Platform
django_theme_academy-0.3.13-py2.py3-none-any.whl Python 3, Python 2 none any Details

Total release size: 456.9 kB

Release files / django_theme_academy-0.3.13.tar.gz

Download URL django_theme_academy-0.3.13.tar.gz
Size 227.0 kB
Tags Source
SHA-256 checksum
How to use checksums
09bf0fc8106e80079beeeedd1d31386fff29f6b7a37c9ac22dd05d8bb50546df
BLAKE2b-256 checksum
How to use checksums
654be161bd69c4828915cf04abfd6094f58dea1482c60025d4c08f58e7d22f68
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.5

Release files / django_theme_academy-0.3.13-py2.py3-none-any.whl

Download URL django_theme_academy-0.3.13-py2.py3-none-any.whl
Size 229.9 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
68ed002fbb680b3c63dd5ac12b87a57b791466fb4d710f74a3b38a15685acb34
BLAKE2b-256 checksum
How to use checksums
051ffdd4b86c626dc2896e52b2310cb16008441f62a5b7c1d516a2f094046e0f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.5

Security for django-theme-academy 0.3.13

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page