Skip to content

Commit d7dcfba

Browse files
authored
fix: Log out user menu on Django 5.0 (#512)
* fix: "Django administration > Log out user" menu not working on Django 5.0 * fix:Restored the initial commit
1 parent 1428c0d commit d7dcfba

File tree

3 files changed

+45
-6
lines changed

3 files changed

+45
-6
lines changed

djangocms_admin_style/sass/components/_header.scss

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,40 @@
131131
background: $color-primary;
132132
}
133133
}
134+
form {
135+
box-shadow: none;
136+
margin: 0;
137+
padding: 0;
138+
button {
139+
float: none;
140+
white-space: nowrap;
141+
line-height: 30px;
142+
height: 30px;
143+
padding: 0 10px 0 15px !important;
144+
cursor: pointer;
145+
146+
border: none !important;
147+
border-radius: 0 !important;
148+
width: 100% !important;
149+
color: $black !important;
150+
font-size: $font-size-normal !important;
151+
font-family: $base-font-family !important;
152+
text-align: left;
153+
154+
&:active,
155+
&:focus {
156+
filter: none !important;
157+
box-shadow: none !important;
158+
text-decoration: underline !important;
159+
}
160+
&:hover {
161+
filter: none !important;
162+
color: $white !important;
163+
background: $color-primary !important;
164+
text-decoration: none !important;
165+
}
166+
}
167+
}
134168
}
135169
}
136170
}

djangocms_admin_style/static/djangocms_admin_style/css/djangocms-admin.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

djangocms_admin_style/templates/admin/inc/branding.html

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,16 @@ <h1>{{ site_header|default:_('Django Administration') }}</h1>
2323
</li>
2424
<li class="toolbar-item-navigation-break">-----</li>
2525
{% endif %}
26-
<li>
27-
<a href="{% url 'admin:logout' %}">
28-
<span>{% trans 'Log out' %} {% firstof user.get_short_name user.get_username %}</span>
29-
</a>
30-
</li>
26+
{% if user.is_authenticated %}
27+
<li>
28+
<form method="POST" action="{% url 'admin:logout' %}">
29+
{% csrf_token %}
30+
<button type="submit">
31+
<b>{% trans 'Log out' %} {% firstof user.get_short_name user.get_username %}</b>
32+
</button>
33+
</form>
34+
</li>
35+
{% endif %}
3136
</ul>
3237
</li>
3338
</ul>

0 commit comments

Comments
 (0)