使用选定的操作项扩展 django 模型
在我的应用程序中,我有一组可能是(最多)一个团队的成员的玩家。我正在玩家管理视图中实现自定义操作,在其中选择玩家并与这些玩家创建一个新团队,遵循以下示例:www.jpichon.net/blog/2010/08/django-admin-actions-and-intermediate -pages/
然而,我感觉应该有一种比使用完全定制的模板更少 django 侵入的方法来实现这一点。我的想法是:Team 类的正常 ModelForm 是否可以扩展为接受来自创建团队操作的参数?不过,我很难找到有关该主题的一些文档。
这是我到目前为止所拥有的屏幕截图(遵循上述指南):
我想要导致类似的结果:
使用自定义模板时,第一部分工作正常,但我不知道如何(很好地)延伸Teams 的现有管理页面用于接受操作中的玩家参数。我想第三步(单击“创建团队”按钮后)可以通过覆盖团队模型表单的 save() 方法来完成?
感谢您的帮助!
In my application, I have a set of players who may be a member of (at most) one team. I am implementing a custom action in the player admin view where I select players and create a new team with those players, following the example at: www.jpichon.net/blog/2010/08/django-admin-actions-and-intermediate-pages/
However, I'm sensing that there should be a less django-intrusive way of implementing this than using a fully customized template. What I'm thinking is: can the normal ModelForm for the Team class be extended to accept arguments when coming from the create team action? I struggle to find some documentation on the subject though.
This is a screenshot of what I have so far (following the above guide):
Which I would like to result in something like:
The first part works fine when using the custom template, but I cant figure out how to (nicely) extend the existing admin page for Teams to accept the player arguments from the actions. I suppose the third step (after clicking the 'Create Team' button) can be accomplished by overriding the save() method of the Team Modelform?
Thankful for any assistance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论