11👍
Try setting your language code in settings:
LANGUAGE_CODE = 'fa-ir'
for further reading on translating, rtl, changing date format and other localization things read this django doc.
4👍
Django looks at the TEMPLATES setting to find order to check for templates to render. As such, you can add rtl.css
to the head of the base admin template in order to load the right-to-left css.
-
In a templates sub-directory of your main project directory, create dir
admin
and filebase.html
. Copy the contents of ‘django/contrib/admin/templates/base.html’ from Django’s source to the newly created file.TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [os.path.join(BASE_DIR, 'templates')], # <- add this line
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
] -
In the template, you’ll see
{% block extra_head %}{% endblock %}
. Insert the stylesheet link here, like this-{% block extra_head %}
<link rel='stylesheet' href='{% static 'admin/css/rtl.css' %}' />
{% endblock %}
Now rtl.css
will be loaded whenever any admin page is loaded.
- Django reset_password_confirm TemplateSyntaxError problem
- Disable Django Debugging for Celery
- How to mock chained function calls in python?
- IPython on Windows – No highlighting or Auto-complete
- "The path python3 (from –python=python3) does not exist" error