Skip to content

Commit 8bb564b

Browse files
committed
Fixed for Django 3.0 and added RWD
- On Django 2.1, `admin_static` was deprecated and removed in Django 3.0 in favor of plain `static`. This change is backwards compatible with Django 2.0 and Django 1.11, as it was already just an alias for `static` on those versions of Django. - Added missing admin RWD styles introduced in Django 2.0. This change may introduce some 404 errors on Django 1.11, as those stylesheet files are not present on this Django version. If this is an issue, create `admin/base_site.html` template being an exact copy of original Django `admin/base_site.html` template and add empty `responsive` block into it. - Reverted indentation and HTML tags ending style of customized `admin/base.html` file to match original Django file. This makes spotting any changes of this file in new Django versions easier.
1 parent d63c784 commit 8bb564b

File tree

1 file changed

+74
-68
lines changed

1 file changed

+74
-68
lines changed

admin_toolbox/templates/admin/base.html

Lines changed: 74 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,24 @@
1-
{% load i18n admin_static admin_toolbox_sidebar admin_toolbox_breadcrumbs %}<!DOCTYPE html>
1+
{% load i18n static %}{% load admin_toolbox_sidebar admin_toolbox_breadcrumbs %}<!DOCTYPE html>
22
{% get_current_language as LANGUAGE_CODE %}{% get_current_language_bidi as LANGUAGE_BIDI %}
33
<html lang="{{ LANGUAGE_CODE|default:"en-us" }}" {% if LANGUAGE_BIDI %}dir="rtl"{% endif %}
44
class="{% if request.user.is_authenticated %}w-su-sidebar{% endif %}">
55
<head>
66
<title>{% block title %}{% endblock %}</title>
7-
<link rel="stylesheet" type="text/css" href="{% block stylesheet %}{% static "admin/css/base.css" %}{% endblock %}" />
8-
<link rel="stylesheet" type="text/css" href="{% static "admin_sidebar/font-awesome/css/all.min.css" %}" />
9-
<link rel="stylesheet" type="text/css" href="{% static "admin_sidebar/font-awesome/css/v4-shims.min.css" %}" />
10-
<link rel="stylesheet" type="text/css" href="{% static "admin_sidebar/css/admin-sidebar.css" %}" />
7+
<link rel="stylesheet" type="text/css" href="{% block stylesheet %}{% static "admin/css/base.css" %}{% endblock %}">
8+
<link rel="stylesheet" type="text/css" href="{% static "admin_sidebar/font-awesome/css/all.min.css" %}">
9+
<link rel="stylesheet" type="text/css" href="{% static "admin_sidebar/font-awesome/css/v4-shims.min.css" %}">
10+
<link rel="stylesheet" type="text/css" href="{% static "admin_sidebar/css/admin-sidebar.css" %}">
1111
{% block extrastyle %}{% endblock %}
12-
{% if LANGUAGE_BIDI %}<link rel="stylesheet" type="text/css" href="{% block stylesheet_rtl %}{% static "admin/css/rtl.css" %}{% endblock %}" />{% endif %}
12+
{% if LANGUAGE_BIDI %}<link rel="stylesheet" type="text/css" href="{% block stylesheet_rtl %}{% static "admin/css/rtl.css" %}{% endblock %}">{% endif %}
1313
<script type="text/javascript" src="{% static "admin/js/vendor/jquery/jquery.js" %}"></script>
1414
<script type="text/javascript" src="{% static "admin/js/jquery.init.js" %}"></script>
1515
{% block extrahead %}{% endblock %}
16-
{% block blockbots %}<meta name="robots" content="NONE,NOARCHIVE" />{% endblock %}
16+
{% block responsive %}
17+
<meta name="viewport" content="user-scalable=no, width=device-width, initial-scale=1.0, maximum-scale=1.0">
18+
<link rel="stylesheet" type="text/css" href="{% static "admin/css/responsive.css" %}">
19+
{% if LANGUAGE_BIDI %}<link rel="stylesheet" type="text/css" href="{% static "admin/css/responsive_rtl.css" %}">{% endif %}
20+
{% endblock %}
21+
{% block blockbots %}<meta name="robots" content="NONE,NOARCHIVE">{% endblock %}
1722
</head>
1823
{% load i18n %}
1924

@@ -24,74 +29,75 @@
2429
<div id="container">
2530

2631
{% if not is_popup %}
27-
<!-- Header -->
28-
<div id="header">
29-
<div id="branding">
30-
{% block branding %}{% endblock %}
31-
</div>
32-
{% block usertools %}
33-
{% if has_permission %}
34-
<div id="user-tools">
35-
{% block welcome-msg %}
36-
{% trans 'Welcome,' %}
37-
<strong>{% firstof user.get_short_name user.get_username %}</strong>.
38-
{% endblock %}
39-
{% block userlinks %}
40-
{% if site_url %}
41-
<a href="{{ site_url }}">{% trans 'View site' %}</a> /
42-
{% endif %}
43-
{% if user.is_active and user.is_staff %}
44-
{% url 'django-admindocs-docroot' as docsroot %}
45-
{% if docsroot %}
46-
<a href="{{ docsroot }}">{% trans 'Documentation' %}</a> /
47-
{% endif %}
48-
{% endif %}
49-
{% if user.has_usable_password %}
50-
<a href="{% url 'admin:password_change' %}">{% trans 'Change password' %}</a> /
32+
<!-- Header -->
33+
<div id="header">
34+
<div id="branding">
35+
{% block branding %}{% endblock %}
36+
</div>
37+
{% block usertools %}
38+
{% if has_permission %}
39+
<div id="user-tools">
40+
{% block welcome-msg %}
41+
{% trans 'Welcome,' %}
42+
<strong>{% firstof user.get_short_name user.get_username %}</strong>.
43+
{% endblock %}
44+
{% block userlinks %}
45+
{% if site_url %}
46+
<a href="{{ site_url }}">{% trans 'View site' %}</a> /
47+
{% endif %}
48+
{% if user.is_active and user.is_staff %}
49+
{% url 'django-admindocs-docroot' as docsroot %}
50+
{% if docsroot %}
51+
<a href="{{ docsroot }}">{% trans 'Documentation' %}</a> /
5152
{% endif %}
52-
<a href="{% url 'admin:logout' %}">{% trans 'Log out' %}</a>
53-
{% endblock %}
54-
</div>
55-
{% endif %}
53+
{% endif %}
54+
{% if user.has_usable_password %}
55+
<a href="{% url 'admin:password_change' %}">{% trans 'Change password' %}</a> /
56+
{% endif %}
57+
<a href="{% url 'admin:logout' %}">{% trans 'Log out' %}</a>
5658
{% endblock %}
57-
{% block nav-global %}{% endblock %}
5859
</div>
59-
<!-- END Header -->
60-
{% rebreadcrumbs %}
61-
{% block breadcrumbs %}
62-
<div class="breadcrumbs">
63-
<a href="{% url 'admin:index' %}">{% trans 'Home' %}</a>
64-
{% if title %} &rsaquo; {{ title }}{% endif %}
65-
</div>
66-
{% endblock %}
67-
{% endrebreadcrumbs %}
68-
{% if request.user.is_authenticated %}
69-
<div id="su-content">
70-
{% admin_sidebar_content %}
7160
{% endif %}
61+
{% endblock %}
62+
{% block nav-global %}{% endblock %}
63+
</div>
64+
<!-- END Header -->
65+
{% rebreadcrumbs %}
66+
{% block breadcrumbs %}
67+
<div class="breadcrumbs">
68+
<a href="{% url 'admin:index' %}">{% trans 'Home' %}</a>
69+
{% if title %} &rsaquo; {{ title }}{% endif %}
70+
</div>
71+
{% endblock %}
72+
{% endrebreadcrumbs %}
73+
{% if request.user.is_authenticated %}
74+
<div id="su-content">
75+
{% admin_sidebar_content %}
76+
{% endif %}
7277
{% endif %}
7378

74-
{% block messages %}
75-
{% if messages %}
76-
<ul class="messagelist">{% for message in messages %}
77-
<li{% if message.tags %} class="{{ message.tags }}"{% endif %}>{{ message|capfirst }}</li>
78-
{% endfor %}</ul>
79-
{% endif %}
80-
{% endblock messages %}
79+
{% block messages %}
80+
{% if messages %}
81+
<ul class="messagelist">{% for message in messages %}
82+
<li{% if message.tags %} class="{{ message.tags }}"{% endif %}>{{ message|capfirst }}</li>
83+
{% endfor %}</ul>
84+
{% endif %}
85+
{% endblock messages %}
8186

82-
<!-- Content -->
83-
<div id="content" class="{% block coltype %}colM{% endblock %}">
84-
{% block pretitle %}{% endblock %}
85-
{% block content_title %}{% if title %}<h1>{{ title }}</h1>{% endif %}{% endblock %}
86-
{% block content %}
87-
{% block object-tools %}{% endblock %}
88-
{{ content }}
89-
{% endblock %}
90-
{% block sidebar %}{% endblock %}
91-
<br class="clear" />
92-
</div>
93-
<!-- END Content -->
94-
{% block footer %}<div id="footer"></div>{% endblock %}
87+
<!-- Content -->
88+
<div id="content" class="{% block coltype %}colM{% endblock %}">
89+
{% block pretitle %}{% endblock %}
90+
{% block content_title %}{% if title %}<h1>{{ title }}</h1>{% endif %}{% endblock %}
91+
{% block content %}
92+
{% block object-tools %}{% endblock %}
93+
{{ content }}
94+
{% endblock %}
95+
{% block sidebar %}{% endblock %}
96+
<br class="clear">
97+
</div>
98+
<!-- END Content -->
99+
100+
{% block footer %}<div id="footer"></div>{% endblock %}
95101
{% if not is_popup and request.user.is_authenticated %}</div>{% endif %}
96102

97103
</div>

0 commit comments

Comments
 (0)