如何在 Django Admin 中保存后保留过滤器选择
首先,我确实看过这个问题,但它已经存在一年多了。当然,现在 Django 1.1.1 中有一个好方法可以在用户单击管理中的保存按钮后继续进行过滤器选择。
在一个有数千条记录的表中,过滤是必不可少的。如果用户做出了多个过滤器选择,则不必重复进行。
First, I did look at this question, but its over a year old. Surely now there is a good way in Django 1.1.1 to carry filter selection forward after a user clicks the save button in the Admin.
In a table with thousands of records, filtering is essential. And if a user makes several filter choices that effort shouldn't have to be repeated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
答案仍然是一样的:Django 开箱即用不支持这种行为。问题跟踪器中有几个带有补丁的票证:#3777、#6903。 此注释中的中间件类无需修改 Django 代码即可工作。
The answer is still the same: out of the box, Django doesn't support this behavior. There are a couple of tickets in the issue tracker with patches: #3777, #6903. The middleware class in this comment works without modifying Django code.
此功能已作为 1.6 版本的一部分添加到 Django,并且现在默认启用。 发行说明中对此进行了描述:
This feature has been added to Django as part of the 1.6 release and is enabled now by default. It is described in the release notes:
另一种方法是使用此代码段 http://djangosnippets.org/snippets/2531/
好东西是你不需要破解任何东西。
another way is to use this snippet http://djangosnippets.org/snippets/2531/
the good thing is you don't have to hack anything.
这个功能已经向 Django 项目提出了很长时间的请求(ticket 开了 5 年前)。
幸运的是,这种恼人的行为已在主干中修复。预计它会包含在 Django 1.6 中。
This feature has been a request to the Django project for a long time (the ticket was opened 5 years ago).
Fortunately this annoying behavior was fixed in trunk. Expect it to be included in Django 1.6.
以下是我在
render_change_form
中所做的操作,以使用preserved_filters
生成后退按钮。Here's what I did inside
render_change_form
to generate a back button withpreserved_filters
.