Django admin - adding actions in Add page view - django

I have a question about admin: i've defined an admin action 'create pdf', now i can see it in the select widget of the changelist view.
I'd like to see it as a button in the add page, i've specified both actions_on_bottom and actions_on_top to True, but i see only the usual buttons (save and add another, save and continue, save).
how can i fix it?
thanks, Luke.

Actions are only registered to the dropdown menus you'll have to add a button with javascript or override the changelist template(s)

Related

is there any way to add button to django admin?

i want a button to call a view function from django admin. i want my button here my django admin panel
When i click on that button , it calls a specified view.
You have to override the default django admin template. Please read more here: https://docs.djangoproject.com/en/3.0/howto/overriding-templates/

Django how to change the admin panel template

I am trying to change what is displayed when I click on a model in the django admin. For example if I have the model Book and then I go into the admin panel and click book, it will give me all the fields that I created the model with.
But I want to edit that page that shows all that data. For example, if I click on the "Book" model in the admin panel and see my fields to edit, I want to put another bit of fields on the bottom from another model. Or maybe I want to put like a "Similar Books" list. Is it possible to edit this page?
Admin customization information is here. You can do stuff like list_display or fieldsets etc.

How to make radio buttons in Django admin

Does Django itself provide radio button models?
I was trying to find out how to make radio buttons in Django admin, but since there is nothing related to that, It seems like Django doesn't have radio buttons as default.
This is too late but could be useful for other
you can define the radio button in your admin like this:
radio_fields = {'gender': admin.VERTICAL}
Django model with choices will make use of select by default. To use radio buttons, you will have to to use the RadioSelect widget. See django docs

Customize form actions in django admin

I have followed this article on "How to Add Custom Action Buttons to Django Admin" https://medium.com/#hakibenita/how-to-add-custom-action-buttons-to-django-admin-8d266f5b0d41 and I have it almost working. I would like display fields that are pre-populated with values from my model.
Here is what I have so far.
From this page the user can click on the 'Approve' or 'Deny' buttons.
The deny form is simple and looks like this:
Here the user needs to type in a reason for denying and then can click the Submit button to execute custom code to process the denial.
If the user clicks Approve I would like the user to have the ability to adjust some of the values in my Command model so I need to display those values in the form. So the form would look much like the standard django admin Change form but with just a Submit button that when clicked would update the model with user's changes and call my custom code to process the approval. So the Approval form would look something like this:
But I cannot figure out how to get the values for nonroot_risk and nopasswd_risk from my model to display in the form.

How to add a button in Django admin form?

I want to add a button which has same functionality as SAVE button in DJango and I want to modifying it's response_change function .
How do I do that ?
https://djangosnippets.org/snippets/2005/
---This link helped to add a button in django .