且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在Django 1.4中自定义管理过滤器

更新时间:2023-01-26 17:07:08

在v1.4中引入了新的django.contrib.admin.SimpleListFilter,满足您的需要,官方文档提供了示例代码,读。
本节中搜索SimpleListFilter 。


I am a newbie in Python and Django Development, I learned a lot from the easy read examples provided by the community. But recently I want to implement a customized admin filter for the admin console shipped with Django. I searched a lot and only found some out-of-date approaches to get it done. Such as: Custom Filter in Django Admin on Django 1.3 or below

I tried to read the source code for the filters module in 'django.contrib.admin' app, but unfortunately I can hardly understand the rationale behind the codes. So I wonder whether some kind people could supply some examples or references to this issue --- How to customize admin filter in Django 1.4 ?

Thanks in advance!

There is new django.contrib.admin.SimpleListFilter introduced in v1.4 meet your need, and official document provide sample code and easy to read. search SimpleListFilter in this section.