Hi everyone, I hope you are fine.
I want to customize django admin panel and I have done some steps such as declaring staticfile_dirs and templates dir in setting.py and creating two directories (templates, static) in the project directory as you can see below:
But when I customize something in base.css, I cannot see any changes in the admin panel page and also in the inspect element despite the base.css has been changed.
I will thank if anyone give me a piece of guidance about this matter.
See the thread at Changes in CSS (Style sheet) not reflecting in the Page
Thank you dear Mr. Whitesell.
By the way, have you ever customized django admin with tailwind css ?
No I have not. I know a number of people who are big fans of Tailwind, but I have not yet tried it.
Dear Mr. Whitesell, I have run the command of collectstatic and all of the admin css files have been moved to a static category in the BASE_DIR directory; But unfortunately the css of admin aren’t loaded from this category and the css files are loaded from the static category in venv/Lib/site-packages/django/contrib/admin/static.
I will thank to tell me how can I solve this.
See the docs at ModelAdmin
asset definitions.
Thank you.
By the way I have just found how to use tailwind to style django admin and I am going to customize it completely.
But there is only one problem that there are a lot of html pages for admin panel that I don’t know which of them is for which page of panel and I also need the default django template tags and commands that is written inside admin templates but the html files are very complicated and it is really difficult to find the elements to style them.
Can you give me a suggestion about this please?
Thanks.
That’s something I’ve never bothered with.
We adhere strictly to the principle stated in the docs at The Django admin site | Django documentation | Django
The admin’s recommended use is limited to an organization’s internal management tool. It’s not intended for building your entire front end around.
We consider the admin tool to be just that - a tool. It’s not our site’s front-end from any perspective and only used by an extremely limited number of people (2). Therefore, we don’t expend any effort to style that site - it is what it is.
Dear Mr.Whitesell, I don’t mean that.
I am really satisfied of working with django admim but I only want to know that in which pages of panel, html files are used?
( for example exactly in which pages of panel, change_form.html and other html files are used)
There is no way to identify a definitive list. Just about everything in the Admin is configurable and dynamic. For example, just looking at change_form.html
, you have the following in the render_change_form
method in the ModelAdmin class:
return TemplateResponse(request, form_template or [
"admin/%s/%s/change_form.html" % (app_label, opts.model_name),
"admin/%s/change_form.html" % app_label,
"admin/change_form.html"
This is showing you that for any given change_form
, 4 different locations are searched to find the template to be used. So you could have a situation where ModelA in AppA uses a different template than ModelA in AppB. Or that ModelA in AppA uses a different template than ModelB in AppA.