若是您正在尋找與Django 1.8兼容的版本,只需安裝0.3.7.1。html
pypi(推薦)django
$ pip install bootstrap-admin
django.contrib.admin以前在INSTALLED_APPS中添加bootstrap_adminbootstrap
INSTALLED_APPS = ( # ... 'bootstrap_admin', # always before django.contrib.admin 'django.contrib.admin', # ... )
側邊欄菜單api
它是默認啓用的。可是若是刪除django.template.context_processors。來自context_processors的請求。app
setting中設置禁用側邊欄菜單url
BOOTSTRAP_ADMIN_SIDEBAR_MENU = False
若是但願使用本身的品牌logo,能夠經過覆蓋login.html和base_site來實現html,就像Django管理同樣。確保正確配置了settings.py中的模板設置:spa
TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', 'DIRS': [os.path.join(BASE_DIR, 'my_django_project/templates')], 'APP_DIRS': True, # other stuff }, ]
你必須設置模板的位置,一個絕對路徑。code
假設BASE_DIR是:htm
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
建立全局模板文件夾的這種模式對於您用於base.html和其餘全局模板可能頗有用。blog
更多信息:
https://docs.djangoproject.com/en/2.1/ref/templates/api/ # configuring-an-engine
示例結構
├── my_django_project │ ├── core │ │ ├── admin.py │ │ ├── apps.py │ │ ├── models.py │ │ ├── tests.py │ │ └── views.py │ ├── settings.py │ ├── templates │ │ └── admin │ │ ├── base_site.html │ │ └── login.html │ ├── urls.py │ └── wsgi.py ├── manage.py
您能夠看到,我建立了一個全局模板/文件夾,admin/中還有一個目錄包含login.html和base_site.html。
它們各自的內容以下:
base_site.html
{% extends 'admin/base_site.html' %} {% load static %} {% block branding %} <a href="{% url 'admin:index' %}" class="django-admin-logo"> <!-- Django Administration --> <img height="60" src="{% static "bootstrap_admin/img/logo-140x60.png" %}" alt="{{ site_header|default:_('Django administration') }}"> </a> {% endblock branding %}
login.html
{% extends 'admin/login.html' %} {% load i18n static %} {% block branding %} <a href="{% url 'admin:index' %}" class="django-admin-logo"> <!-- Django Administration --> <img height="60" src="{% static "bootstrap_admin/img/logo-140x60.png" %}" alt="{{ site_header|default:_('Django administration') }}"> </a> {% endblock branding %}
更多信息:
https://docs.djangoproject.com/en/2.1/ref/contrib/admin/#admin-overriding-templates