Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Logout button is not styled with django 4.1 #246

Closed
merwok opened this issue Jan 23, 2023 · 16 comments
Closed

Logout button is not styled with django 4.1 #246

merwok opened this issue Jan 23, 2023 · 16 comments
Assignees
Labels
bug Something isn't working

Comments

@merwok
Copy link
Contributor

merwok commented Jan 23, 2023

Python version
3.11, but irrelevant

Django version
4.1.5

Package version
0.24.2

Current behavior (bug description)
With django 4.1, the logout link in the top bar becomes a form, which is not styled like the other items.

Expected behavior
Should look like the other items 🙂

@merwok merwok added the bug Something isn't working label Jan 23, 2023
@merwok
Copy link
Contributor Author

merwok commented Jan 24, 2023

I see it working now 😮

@merwok merwok closed this as not planned Won't fix, can't repro, duplicate, stale Jan 24, 2023
@fabiocaccamo
Copy link
Owner

Caching?

@saymoncoppi
Copy link

Hello Fabio!
I'm using Django 4.1.5 and django-admin-interface v0.26. This behavior also appears here.

@fabiocaccamo
Copy link
Owner

@saymoncoppi clear the cache / force reload

@saymoncoppi
Copy link

Nop. still not working. Could you help me?

@fabiocaccamo
Copy link
Owner

@saymoncoppi I'm using this library on more than one project running on latest django version and it works fine.

Are you using STATICFILES_STORAGE = "django.contrib.staticfiles.storage.ManifestStaticFilesStorage" ?

@saymoncoppi
Copy link

saymoncoppi commented Aug 28, 2023 via email

@fabiocaccamo
Copy link
Owner

Could you try to set STATICFILES_STORAGE and re-collect static files?

@saymoncoppi
Copy link

image

Same behavior. if I select the text there it appear showing that the element is in the right place.
image

@fabiocaccamo
Copy link
Owner

fabiocaccamo commented Aug 28, 2023

Have you the same problem with all browsers?
Could you paste here the CSS that would solve the issue?

@saymoncoppi
Copy link

The same behavior is happening using Chrome and Edge. I haven't fixed it yet. I´ll try here...

@saymoncoppi
Copy link

Hello @fabiocaccamo!

I´m just sharing the solution applied here. IDK if is a better one but works fine, ok?

I checked out the source code from both projects and made a custom base_site.html mixing with that content to handle this issue.

I'm proud of this LOL! Take a look...

{% extends "admin/base_site.html" %}
{% load i18n %}
{% block userlinks %}
    {% if site_url %}
        <a href="{{ site_url }}">{% translate 'View site' %}</a> /
    {% endif %}
    {% if user.is_active and user.is_staff %}
        {% url 'django-admindocs-docroot' as docsroot %}
        {% if docsroot %}
            <a href="{{ docsroot }}">{% translate 'Documentation' %}</a> /
        {% endif %}
    {% endif %}
    {% if user.has_usable_password %}
    <a href="{% url 'admin:password_change' %}">{% translate 'Change password' %}</a> /
    {% endif %}
    <form id="logout-form" method="post" action="{% url 'admin:logout' %}">
        {% csrf_token %}
        <button type="submit" style="color:#666">{% translate 'Log out' %}</button>
    </form>

    {% load admin_interface_tags %}
    {% get_admin_interface_theme as theme %}
    {% if theme.language_chooser_active %}
        {% get_admin_interface_languages as languages %}
        {% include "admin_interface/language_chooser.html" %}
    {% endif %}
{% endblock %}

Sources:
https://github.com/django/django/blob/main/django/contrib/admin/templates/admin/base.html
https://github.com/fabiocaccamo/django-admin-interface/blob/main/admin_interface/templates/admin/base_site.html

@fabiocaccamo
Copy link
Owner

Why you have extended the html template to solve a css problem?

Have you understood/isolated the cause?

@saymoncoppi
Copy link

Hello Fabio!

You are right about exploring the reason why I did that. Seems like a bite over to fix a CSS issue.
But since I could not fix the issue earlier I tried this action to help me to go further.
And finally due you're smarter than me about the issues, you forced me to chase another fix using CSS and less content into base_site.

made a css\extra_base_site.css

#logout-form button {
  color: #747474;
}

#logout-form button:hover {
  color: #333333;
}

and apply to template\base_site.html

{% extends "admin/base_site.html" %}
{% load i18n %}
{% load static %}
{% block extrastyle %}
{{ block.super }}
<link rel="stylesheet" type="text/css" href="{% static 'css/extra_base_site.css' %}"    />
{%endblock%}

Got it fixed in a smarter way, tks...

But, seems like maybe has another way to fix it, Could you check if the CSS class was missing from:
https://github.com/fabiocaccamo/django-admin-interface/blob/main/admin_interface/static/admin_interface/css/admin-interface.css

Let me know what you discover, ok?
Tks again for all your support.

@fabiocaccamo
Copy link
Owner

This is was what I needed, thank you for investigating the problem, I will enforce the colors using css variables in the next release.

#logout-form button {
  color: #747474;
}

#logout-form button:hover {
  color: #333333;
}

@saymoncoppi
Copy link

saymoncoppi commented Aug 31, 2023

Great!!! Now I can be proud. lol

since I was trying to improve the appearance of userlink block I realised that we could also adjust the CSS of language-selector for a better experience on different media sizes. I´ll open a new issue to share there properly,

Tks again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants