A
A
Alexander2015-09-18 08:37:44
Django
Alexander, 2015-09-18 08:37:44

Own buttons (functions) in the jungi admin panel?

There is a need to perform some self-written functions within the Junga admin panel. Now they are implemented through commands and are called from the console. But you need to bring them to the admin panel so that the site administrator can use them without resorting to the help of the console.
For example, " reset the cache " or " recalculate the tree of menu categories ". All of them are quickly completed, they do not eat resources. But I don’t know how to shove them into the dzhang admin panel. Options with overriding the model or the admin class of the save () function, with sticking a function call there, are not suitable. For it is necessary to cause not at each change and not always. Plus not always work with one object.
Option with " make a separate admin panel" is not needed. I know, I can. But for the sake of 2-5 small buttons, moreover, associated with specific models, it is not advisable to fence the bike.
I'm looking in the direction of AdminSite for now . But maybe someone has a code example or other thoughts, with embedding button/link/interstitial page where would a third party function be called?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
marazmiki, 2015-09-18
@syschel

The admin panel is essentially an old version of CBV. The only difference is that it specifies not a single view, but a set. And the url scheme is a bonus. And there are standard tools to add an arbitrary set of your own view actions to each ModelAdmin class. Even the documentation says .
How to make buttons: I don’t know how about now, but just a year ago, for this it was necessary to redefine the admin template for a specific application (see about redefining templates in the admin ). Or a simpler option is to write JS that will add the HTML code of the buttons to the page, and connect this JS via Media .

D
devel787, 2015-09-21
@devel787

Perhaps something will help djbook.ru/examples/63

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question