Created
January 29, 2016 15:42
-
-
Save un-def/50d1cd3d6f15e6d9f212 to your computer and use it in GitHub Desktop.
Django admin site lang switcher
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- {templates_dir}/admin/base_site.html --> | |
{% extends "admin/base.html" %} | |
{% load i18n %} | |
{% block title %}{{ title }} | {{ site_title|default:_('Django site admin') }}{% endblock %} | |
{% block branding %} | |
<h1 id="site-name"><a href="{% url 'admin:index' %}">{{ site_header|default:_('Django administration') }}</a></h1> | |
{% endblock %} | |
{% block usertools %} | |
{% if has_permission %} | |
<div id="user-tools"> | |
{% block welcome-msg %} | |
{% trans 'Welcome,' %} | |
<strong>{% firstof user.get_short_name user.get_username %}</strong>. | |
{% endblock %} | |
{% block userlinks %} | |
{% get_current_language as cur_lang %} | |
{% get_available_languages as langs %} | |
[ | |
{% for lang in langs %} | |
{% if lang.0 == cur_lang %} | |
<strong>{{ lang.0 }}</strong> | |
{% else %} | |
<a href="?langswitch={{ lang.0 }}">{{ lang.0 }}</a> | |
{% endif %} | |
{% if not forloop.last %}|{% endif %} | |
{% endfor %} | |
] / | |
{% if site_url %} | |
<a href="{{ site_url }}">{% trans 'View site' %}</a> / | |
{% endif %} | |
{% if user.is_active and user.is_staff %} | |
{% url 'django-admindocs-docroot' as docsroot %} | |
{% if docsroot %} | |
<a href="{{ docsroot }}">{% trans 'Documentation' %}</a> / | |
{% endif %} | |
{% endif %} | |
{% if user.has_usable_password %} | |
<a href="{% url 'admin:password_change' %}">{% trans 'Change password' %}</a> / | |
{% endif %} | |
<a href="{% url 'admin:logout' %}">{% trans 'Log out' %}</a> | |
{% endblock %} | |
</div> | |
{% endif %} | |
{% endblock %} | |
{% block nav-global %}{% endblock %} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment