百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
D

django-bootstrap-themes

> 编程语言
开源

Django 支持多个 Bootstrap 主题

100 stars0 点赞3 次浏览
访问官网GitHub

工具介绍

Django 支持多个 Bootstrap 主题

django-bootstrap-themes


NOTE: This project is outdated, but with donations I'd love to make time to update it. Check out the Sponsor button if you're interested in seeing this project updated for the latest Django and Bootstrap.


Bootstrap theme support for Django, includes themes from Bootswatch.

  • Bootstrap
  • Bootswatch

Installation

django-bootstrap-themes can be installed via pip:

bash
pip install django-bootstrap-themes

or by copying the bootstrap_themes directory into your Django project.

Configuration

To configure django-bootstrap-themes in your project, first add it to the installed apps in your Django settings:

python
INSTALLED_APPS = (
    # Django apps
    'bootstrap_themes',
    # Other apps
)

Once you've added it to your installed apps, you can use the template tags to get the CSS and JS files for Bootstrap:

  • Loading the templatetags
django
{% load bootstrap_themes %}
  • Getting the CSS files (use the theme parameter to select the theme and the type parameter to choose between CSS, minified CSS, or LESS format for the stylesheets)
django
{% bootstrap_styles theme='default' type='min.css' %}
{% bootstrap_styles theme='cosmo' type='css' %}
{% bootstrap_styles theme='united' type='less' %}
  • Getting the Javascript files (select minified or not with the use_min parameter)
django
{% bootstrap_script use_min=True %}

As with any Django templatetags, you can use variables for the parameters, thus making it easy to switch themes, and even make the theme user-configurable.

If you want to make the theme user configurable, there is a handy function to return the list of included themes as a choices list for a CharField, like this:

python
from django.db import models
from bootstrap_themes import list_themes

class MyModel(models.Model):
    theme = models.CharField(max_length=255, default='default', choices=list_themes())

Then in your templates, you can use the value of the theme field as the theme parameter to bootstrap_styles.

Issues· 3 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

Python

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月18日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言