Commits

salvator committed 86ae6a1

site name in navbar and title

Comments (0)

Files changed (3)

 Insert `admintools_bootstrap` to your INSTALLED_APPS before `admin_tools` and `django.contrib.admin` apps.
 
 Enjoy.
+
+
+Site name in navigation bar and title
+------------------------------------
+
+admintools-bootstrap can use current site to display site name in admin interface.
+
+To enable this feature, add `django.contrib.sites` to your `INSTALLED_APPS` list (if you have not yet), and `admintools_bootstrap.context_processors.site` to `TEMPLATE_CONTEXT_PROCESSORS` list.

admintools_bootstrap/context_processors.py

+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+from django.contrib.sites.models import Site
+
+def site(request):
+    """
+        adds `site` template variable
+    """
+    return {'site': Site.objects.get_current()}

admintools_bootstrap/templates/admin/base_site.html

 {% extends "admin/base.html" %}
 {% load i18n admin_tools_menu_tags %}
 
-{% block title %}{{ title }} | {% trans 'Django site admin' %}{% endblock %}
+{% block title %}{{ title }} | {% if site %}{{ site.name }} {% trans "admin" %}{% else %}{% trans 'Django site admin' %}{% endif %}{% endblock %}
 
 {% block extrastyle %}
 {{ block.super }}
 {% endblock %}
 
 {% block branding %}
-<a class="brand">{% trans 'Django administration' %}</a>
+<a class="brand">{% if site %}{{ site.name }} {% trans "admin" %}{% else %}{% trans 'Django admin' %}{% endif %}</a>
 {% endblock %}
 
 {% block nav-global %}