First of all i'm new to django
. and i'm amazing from this cool framework (not in database
part and mysql
connector)
And When i looking to django admin style folder in css folder ,
i see rtl css , but now i don't know how can i change admin style to rtl
.
This is screen shot from my folders
Thank's
To do so, you will have to change the project's settings.py . Find the TEMPLATES section and modify accordingly. To override the default template you first need to access the template you want to modify from the django/contrib/admin/templates/admin directory.
As noted above, your own Django models can also present their fields for editing in the frontend. This is achieved by using the FrontendEditableAdminMixin base class.
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.
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 file base.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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With