I am sing grappelli, the admin pages look good, but now I need modify some pages, for example, I created templates/admin/index.html under my app, it works, but grappelli doesn't apply the style on this customized template, any idea how I can make it work as the default admin templates?
figured out, I need customize on the grappelli template files not the default admin template files
Related
In my Django admin. If I delete anything in superadmin or inside an user created by superadmin it shows a confirmation page. I have delete_confirmation.html in my templates under my admin and in my another app.
If I change anything in it or add a line it doesn't change plus it shows objects in my page which I don't want. I don't know how to override it. Please refer to the image. My delete confirmation page
To override any template in a django project, you need to replicate the path of the template in your project's template directory.
This template is found in contrib/admin/templates/admin/delete_confirmation.html
Therefore in your template directory create a directory called admin and then delete_confirmation.html in that. This overrides the django template path in your templates.
You can then put whatever you want in it & repeat this for any other templates from installed packages.
Docs on overrides of admin templates; https://docs.djangoproject.com/en/3.0/ref/contrib/admin/#admin-overriding-templates
I wish to do some Django admin customization, on which I require the filter panel to be placed at top of the page. Can we also update the other templates as well in some fashion? I have read the official docs for Django admin, but I am unable to implement as I am new to Django and frontend.
You can override and extend the default Django admin template files, and do any sort of changes to the UI, by writing your own admin template files.
As you know, there are several admin themes available for Django, you can go through them, and refer to how these themes are implemented (reading their code) and try making up one for your own as per your needs.
You can read about overriding Django templates -
Already answered question - How to Override and extend basic django admin templates?
Django Documentation - https://docs.djangoproject.com/en/2.0/ref/contrib/admin/#admin-overriding-templates
You can also refer to the following directory on GitHub, which contains all the original Django admin template files, which you can override/extend - https://github.com/django/django/tree/master/django/contrib/admin/templates/admin
What's the best way to share a bootstrap template between my own django app and the admin app?
I've got bootstrap working just fine for my own app - including a link in a menu to the admin app. I've also installed django-admin-bootstrapped, but that just gives me a completely separate bootstrap template.
I'd like my template to apply to both my own app and to the admin, so that my sysadmin users see the admin link and, when they're in the admin app, still see everything looking consistent and can easily get back to the main app.
Well you can just override the base admin template and use it in your app, take a look here overriding admin templates
But you can use the same base file for both the admin and your app views
My admin page for a specific model has two stackedInlines. Currently they display one under the other. I would like them to display side by side so The page would look like this (don't have enough reputation to embed the image :[ )
Any easy way to go about this without having to write my own admin page?
If that's the only solution, how exactly would I go about that?
you can override Django admin template for each app in your project.
you just have too create same folder as your app in template directory and overriding html.
How to override and extend basic Django admin templates?
You can add CSS/Javascript to admin page by defining class Media.
You'll have to override the admin template to accomplish this. See roshan's answer for more info.
I need to plug in reach text editor to admin page of flatpages. And I don't know, what the template are used to falatpages administration?
Update:
One way is to use the django-tinymce app which supports the TinyMCE rich text editor. There's also an example of using the widget with a flatpage form.
Old:
The default template should reside at "flatpages/default.html" but you can customize this through the admin interface. See the Flatpage templates section in the django docs for more information.
In addition to answer to my question. For admin panel of flatpage used default chenge_form.html. But if you customized it for your app, it wouldn't be work for flatpages without explicit destination.