您可以将参数添加到Django自定义管理员操作中吗? [英] Can you add parameters to Django custom admin actions?

查看:265
本文介绍了您可以将参数添加到Django自定义管理员操作中吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

例如(不是这样,仅是为了说明),如果我想添加一个动作以将所选项目中的特定字段设置为X。是否可以添加一个动作以允许输入X而不是硬编码?

For example (not the case, but just to illustrate) if I wanted to add an action to set a specific field in the selected items to X. Is it possible to add an action to allow X to be entered as opposed to hard coded?

推荐答案

请参阅:提供中间页面的操作

您不能直接从更改列表中进行操作页,但在您的中间页上,您可以使用一个表单,该表单允许用户输入一个值,然后将该值用于操作。

You can't do it right from the changelist page, but on your intermediate page, you could have a form that would allow the user to enter a value, and then use that value for the action.

这篇关于您可以将参数添加到Django自定义管理员操作中吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆