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

查看:38
本文介绍了您可以向 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天全站免登陆