Django Bootstrap Themes

screenshot of Django Bootstrap Themes

Support for multiple Bootstrap themes in Django

Overview

The django-bootstrap-themes project is a Bootstrap theme support for Django, which includes themes from Bootswatch. The project is currently outdated, but the developer is open to updating it with donations. It allows users to easily integrate Bootstrap themes into their Django projects.

Features

  • Bootstrap theme support for Django
  • Includes themes from Bootswatch
  • Easy installation via pip or manual copying of the bootstrap_themes directory
  • Configuration through Django settings
  • Templating tags to easily get CSS and JS files for Bootstrap themes
  • Customizable themes with user-configurable options

Configuration

Once the package is installed, you need to add it to the installed apps in your Django settings. This can be done by including the following line in your settings.py file:

INSTALLED_APPS = [
    ...
    'bootstrap_themes',
    ...
]

After adding it to the installed apps, you can use the provided template tags to access the CSS and JS files for the Bootstrap themes.

Loading the templatetags

To load the templatetags in your template, add the following line at the top of your template file:

{% load bootstrap_styles %}

Getting the CSS files

To include the CSS files for the Bootstrap themes, use the following template tag:

{% bootstrap_styles theme="theme_name" type="css" %}

Replace "theme_name" with the desired theme name, and "type" with "css", "min_css", or "less" to choose the desired format for the stylesheets.

Getting the Javascript files

To include the Javascript files for the Bootstrap themes, use the following template tag:

{% bootstrap_scripts use_min=True %}

Set "use_min" to True if you want to include the minified version of the files.

The template tags also support using variables for the parameters, allowing for easy theme switching and user-configurable themes.

If you want to make the theme user configurable, there is a handy function provided by the package to return the list of included themes as a choices list for a CharField. This can be done as follows:

from bootstrap_themes.models import get_theme_choices

class MyForm(forms.Form):
    theme = forms.ChoiceField(choices=get_theme_choices())

In your templates, you can then use the value of the theme field as the theme parameter for the bootstrap_styles template tag.

Summary

django-bootstrap-themes is a Django package that provides Bootstrap theme support, including themes from Bootswatch. It allows for easy installation and configuration, with convenient template tags to include the CSS and JS files for the Bootstrap themes. The package also supports customizable themes through user-configurable options. However, it is currently outdated, but the developer is open to updating it with donations.