How to override Django admin delete_selected_confirmation.html - django

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

Related

Adding Wagtail to an existing Django app

I'm quite new to Django and Wagtail, and I'm having some difficulty with what I think is a very basic use.
How do I allow Wagtail to edit an existing view's template, while serving that template using Django's serving mechanism?
Assume I have an app (HomePage) created to serve the site's main index (/). I have the HomePage's views set up to render template and certain elements dynamically. Now I want that template to be editable via Wagtail's CMS interface. Something as simple as an image on the frontpage, or a headline.
The closest I've gotten so far has been to follow the Wagtail beginner's tutorial to override the base HomePage class in my app's models.py. That only made my pages available via the /pages/ URL.
Thank you for any help.
Since your site's home page is not a Page object in the Wagtail sense, I'd suggest looking at Wagtail's facilities for managing non-page content - snippets and ModelAdmin would be possible candidates, but I reckon the site settings module would be the best fit.
A Setting model gives you a set of fields which can be configured for display in the Wagtail admin using a 'panels' definition, just like you'd get for a page model - with the important property that only one settings record exists per site. You can retrieve this record within your homepage view or template as shown in the docs, and output it on your template as desired.
One way do that, is to let Wagtail serve your homepage. You will need to change your project's url configuration accordingly, to make wagtail's urls serve the root of your site.
Then, you can pack your dynamic content into a custom template_tag and include in your homepage html template.

Customization of Django admin page to add button

I want to add additional button in the admin page other than save , delete and save and continue button.I do know that I should change the default page of admin but I couldn't able to implement it.I can understand it theortically but not in practical.I want steps to change the default program of Django admin page.I need a demo for it.I need a little brief explaination.
go to your site packages directory then to django then contrib then admin and then templates. There you will find all the templates. Copy the templates, and then in your command line type manage.py collectstatics, now you have your admin templates and your admin statics files. You can modify this button

how to force which base file is used in template

I would like to add custom view/template into the admin which I succeeded . But my issue here is that when I extends the base.html it takes the one from my project template and I would like to be able to tell django to take the one from mezzanine admin (as it is a admin page and i would like to have the same look and feel as the rest of the admin)
Any idea how to force the template resolution ?
There are no special template names in django; "base.html" is just the conventional name for the template at the top of the template inheritance tree (which is not required to have a single parent or any particular structure at all).
In terms of templating, django admin is just another django app. The first step is to figure out which template contains the style and content you want to inherit. For this task, I use django-debug-toolbar, which has a "Templates" panel which makes it very easy to figure out what content is coming from which template.
Looking at a django-debug-toolbar in the admin of a mezzanine site, you probably want to inherit from either "admin/base.html" or "admin/base_site.html" depending on how integrated your view is going to be with the admin site.

How to make customized admin template work with grappelli?

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

Sharing bootstrap template with django 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