Django ModelForm:如何覆盖或检查“save_as”
我需要为 Django Admin 中的实例“saved_as”副本的情况添加一些自定义。我可以在 save()
中执行此操作吗?如果可以,我如何检查 save_as kwarg
? 或者是否有一个我可以在某处重写的 save_as()
方法。我无法找到有关常规 save()
与 save_as = True
之间的过程差异的任何信息。
有人可以给我举个例子或者提示我去哪里吗?
非常感谢您抽出时间!
:)
I need to add some customizations for the case that a instance in Django Admin is "saved_as" a copy. Can I do that in save()
, if so how do I check for the save_as kwarg
?
Or is there a save_as()
method I can override somewhere. I was not able to find any information about the differences in the process between a regular save()
and one with save_as = True
.
Can someone point me to an example or give me an hint where to go?
Thank you very much for your time!
:)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
http://docs.djangoproject。 com/en/dev/ref/contrib/admin/#django.contrib.admin.ModelAdmin.change_view
Save as New 按钮是一个具有特定名称
_saveasnew
的提交元素,意思是您可以通过_saveasnew
POST 参数检查是否按下了该按钮。http://docs.djangoproject.com/en/dev/ref/contrib/admin/#django.contrib.admin.ModelAdmin.change_view
The Save as New button is a submit element with a specific name,
_saveasnew
, meaning you can check whether that button was pressed via the presence of the_saveasnew
POST parameter.