Django:向管理员公开模型方法
示例模型:
class Contestant(models.Model):
first_name = models.CharField(max_length=255)
last_name = models.CharField(max_length=255)
email = models.EmailField()
...
def send_registration_email(self):
...
我希望能够向管理员公开此方法,以便管理人员可以登录并手动调用它。我正在考虑尝试属性属性,但不确定这是否有效。是否也可以公开这样的方法,该方法接受除 self 之外的参数,可能是来自 select 或其他东西的相关对象?
Example model:
class Contestant(models.Model):
first_name = models.CharField(max_length=255)
last_name = models.CharField(max_length=255)
email = models.EmailField()
...
def send_registration_email(self):
...
I'd like to be able to expose this method to the admin so that managers can login and manually call it. I'm thinking about trying property attributes but not sure if that's gonna work. Also is it possible to expose a method like this that takes arguments other than self, possibly related objects from a select or something?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以将其注册为管理操作。
You could register it as an admin action.