django admin panel add a confirmation window - django

I need to add a confirmation window on admin change model submit "save". Smth like this: "Do you really want to apply changes? Yes/No". I need it only for one model and only if the changed model satisfy the other conditions. I can`t override django template for one model cause of using django-admin-tool. How can i do this ?

Related

Enable editing a field in Django admin's list view

Consider a model that stores application forms. I would like to use Django admin to quickly view applications and change their status. I would like to be able to change the status of an application right in the view listing all the applications without having to open each application for editing. So, is it possible to make a field editable right in the admin list view?

Adding multiple items using the raw_id_field popup

I am using the Django admin site and I have a m2m relation which uses raw_id_fields in the admin panel. A user can add an item to the m2m model using the popup window but I would like to be able to select multiple items at once and add them all.
Is this at possible with the current framework or would customisation be needed. If customisations are needed, how would I go about doing that.
django-bulk-admin will do the trick, and it supports other bulk actions in admin.

How to add button in django admin site?

I do want to know how to add button in django admin site.I tried many stuff but I couldn't able to do the stuff.I want to add a reset button for an attribute in the model where it should regenerate the value for the attribute.
You're going to have to edit the admin files to add this button, it may be easier to inject a piece of JavaScript code and a button into the admin template to reset the form fields.

django admin: Adding a textarea and a button that invokes a function

On the main admin screen I want a link that when clicked would bring up a page with a textarea along with a button that when clicked will invoke a python function. That function would return data that would be displayed on the page below the textarea.
If this were a regular page that was part of my app I could easily do this, but I'm not sure how to integrate something like this into my admin page. Everything thing in admin seems to be tied to a model, and this is not. Do I have to create a dummy model for this? Let's say I do create a dummy model, then how do I get django to display my custom template for this?
Can anyone help with this?
You can use this django app: https://github.com/jsocol/django-adminplus to add links at the bottom of the list of models without adding a dummy once.

replace Add with Get on django admin site

I have a model that I don't want user to manually add/delete objects. Instead, I want to have some Get button that once clicked, it executes some code and automatically update the database.
I was able to do similar things via adding my own admin action. However, adding an admin action by default means you have to have at least one object for your model, you select that object and performs some action.
I want be able to perform my customized action on an empty model (if I can replace the Add button with a Get button on the index page, it will be perfect). Is there a way to do so? thanks!
You could override the add_view method of the django admin model and do whatever you felt like having that view do if you wanted. Poke around through the ModelAdmin code and you can see what it does by default
you could also take a look at this project: https://github.com/imtapps/django-admin-ext and see an example of how to register your own urls for an admin... so you could make your view something like admin/myproject/myapp/model/get and have it do what you'd like...
You can prevent users from adding new objects by removing the "Can add ModelName" permission from that user. If they're a superuser that won't actually stop them from doing that, however.
Admin actions are designed to be run on specific instances of the model; if that's not what your code is doing you probably shouldn't go that particular route. You can override the admin template for your model and add a new button or link to your custom view. You could also remove the Add button entirely by eliminating it from your template, but I'd recommend using permissions instead.