django - 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.
解决方案
推荐阅读
- azure - Azure:New-AzCdnProfile:操作返回无效状态代码“BadRequest”
- gis - 在 OpenLayers 中的 EPSG:25832 中显示矢量切片
- ios - 显示具有其他工作表作为父工作表的工作表时,SwiftUI TextField 第一响应者不起作用
- html - css使用颜色从继承颜色,到另一个属性
- matlab - 如何在文本和数字之间只写数字(并将它们转换为列向量),如下所示
- vue.js - 为什么 Vue 不缓存方法结果?
- python - 使用 networkx 或 networkit 从边列表中为多个有向图创建路径表示
- jax-rs - Kumuluzee 微配置文件休息客户端 - 无法在错误响应中获取响应正文
- html - 我该如何搬家
在 ? - django - Django:获取点击按钮的ID