Django 堆叠内联管理问题
使用 Django 1.2,我有一个堆叠的内联管理器,上面有多个字段。我需要根据内联存在的父对象来限制多对多的选择。例如,我有一个位于 Widget
管理中的 WidgetPart
内联组件。当我编辑现有的 Widget
时,我需要根据与正在编辑的 Wiget
相关的逻辑来限制 WidgetPart.foo
选择。我似乎无法使用 formfield_for_manytomany
执行此操作,因为它不仅不提供任何 obj
相关信息,而且它的 request
参数似乎在内联中使用时始终为 None
。还有别的办法吗?
Using Django 1.2 I have a stacked inline admin with a many to many field on it. I need to limit the choices in the many to many based on the parent object that the inline exists for. For example, I have a WidgetPart
inline that's on the Widget
admin. When I'm editing an existing Widget
I need to limit WidgetPart.foo
choices based on logic pertaining to the Wiget
that is being edited. I can't seem to do this with formfield_for_manytomany
, as not only does it not provide any obj
related information, but it's request
argument seems to always be None
when used in an inline. Is there another way?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以在 InlineAdmin 类上执行以下操作:
You can do something like this on your InlineAdmin class: