[Django Code] #5833: newforms-admin enable registering custom FilterSpecs

17 views
Skip to first unread message

Django Code

unread,
Oct 29, 2007, 11:28:51 AM10/29/07
to djang...@holovaty.com, ja...@jacobian.org, django-...@googlegroups.com
#5833: newforms-admin enable registering custom FilterSpecs
---------------------------+------------------------------------------------
Reporter: Honza_Kral | Owner: nobody
Status: new | Component: Admin interface
Version: newforms-admin | Keywords: newforms admin list_filter filterspec
Stage: Unreviewed | Has_patch: 1
---------------------------+------------------------------------------------
I odified the filterspec definition to allow for users to register their
own filters in admin. The mechanism is simple - I just reverted the order
of the registry so that newly registered specs will come first. That way
if you register your own filter via {{{FilterSpec.register}}}, it will be
used before the default one.

--
Ticket URL: <http://code.djangoproject.com/ticket/5833>
Django Code <http://code.djangoproject.com/>
The web framework for perfectionists with deadlines

Django Code

unread,
Dec 1, 2007, 12:12:57 PM12/1/07
to djang...@holovaty.com, ja...@jacobian.org, django-...@googlegroups.com
#5833: newforms-admin enable registering custom FilterSpecs
-----------------------------------------------------+----------------------
Reporter: Honza_Kral | Owner: jkocherhans
Status: assigned | Component: Admin interface
Version: newforms-admin | Resolution:
Keywords: newforms admin list_filter filterspec | Stage: Unreviewed
Has_patch: 1 | Needs_docs: 0
Needs_tests: 0 | Needs_better_patch: 0
-----------------------------------------------------+----------------------
Changes (by jkocherhans):

* owner: nobody => jkocherhans
* needs_better_patch: => 0
* status: new => assigned
* needs_tests: => 0
* needs_docs: => 0

Comment:

I really like the idea behind this, but I'd need to review the code closer
and won't take the time to do it right now since it's a new feature. I'd
rather focus on bugs preventing newforms-admin from being used.

--
Ticket URL: <http://code.djangoproject.com/ticket/5833#comment:1>

Django Code

unread,
Dec 1, 2007, 12:26:06 PM12/1/07
to djang...@holovaty.com, ja...@jacobian.org, django-...@googlegroups.com
#5833: newforms-admin enable registering custom FilterSpecs
-----------------------------------------------------+----------------------
Reporter: Honza_Kral | Owner: jkocherhans
Status: assigned | Component: Admin interface
Version: newforms-admin | Resolution:
Keywords: newforms admin list_filter filterspec | Stage: Unreviewed
Has_patch: 1 | Needs_docs: 0
Needs_tests: 0 | Needs_better_patch: 0
-----------------------------------------------------+----------------------
Comment (by Honza_Kral):

Also see #3400 for another ideas about filters which could benefit from
this scheme...

--
Ticket URL: <http://code.djangoproject.com/ticket/5833#comment:2>

Django Code

unread,
Mar 3, 2008, 10:07:04 PM3/3/08
to djang...@holovaty.com, ja...@jacobian.org, django-...@googlegroups.com
#5833: [newforms-admin] Custom FilterSpecs
--------------------------------------------------+-------------------------
Reporter: Honza_Kral | Owner: jkocherhans
Status: assigned | Component: Admin interface
Version: newforms-admin | Resolution:
Keywords: nfa-someday list_filter filterspec | Stage: Design decision needed
Has_patch: 1 | Needs_docs: 0
Needs_tests: 0 | Needs_better_patch: 0
--------------------------------------------------+-------------------------
Changes (by anonymous):

* stage: Unreviewed => Design decision needed

--
Ticket URL: <http://code.djangoproject.com/ticket/5833#comment:8>

Django Code

unread,
Mar 3, 2008, 10:08:37 PM3/3/08
to djang...@holovaty.com, django-...@googlegroups.com
#5833: [newforms-admin] Custom FilterSpecs
--------------------------------------------------+-------------------------
Reporter: Honza_Kral | Owner: jkocherhans
Status: assigned | Component: Admin interface
Version: newforms-admin | Resolution:
Keywords: nfa-someday list_filter filterspec | Stage: Design decision needed
Has_patch: 1 | Needs_docs: 0
Needs_tests: 0 | Needs_better_patch: 0
--------------------------------------------------+-------------------------
Comment (by jacob):

^^^ that was me; sorry.

--
Ticket URL: <http://code.djangoproject.com/ticket/5833#comment:9>

Django Code

unread,
Mar 19, 2008, 1:28:26 AM3/19/08
to djang...@holovaty.com, django-...@googlegroups.com
#5833: [newforms-admin] Custom FilterSpecs
-----------------------------------------------------------------+----------
Reporter: Honza_Kral | Owner: jkocherhans
Status: assigned | Component: Admin interface
Version: newforms-admin | Resolution:
Keywords: nfa-someday list_filter filterspec nfa-changelist | Stage: Design decision needed
Has_patch: 1 | Needs_docs: 0
Needs_tests: 0 | Needs_better_patch: 0
-----------------------------------------------------------------+----------
Changes (by ales_zoulek):

* keywords: nfa-someday list_filter filterspec => nfa-someday
list_filter filterspec nfa-changelist

--
Ticket URL: <http://code.djangoproject.com/ticket/5833#comment:10>

Django Code

unread,
Jul 10, 2008, 11:18:04 AM7/10/08
to djang...@holovaty.com, django-...@googlegroups.com
#5833: [newforms-admin] Custom FilterSpecs
---------------------------------------------+------------------------------
Reporter: Honza_Kral | Owner: jkocherhans
Status: assigned | Milestone:
Component: Admin interface | Version: newforms-admin
Resolution: | Keywords: nfa-someday list_filter filterspec nfa-changelist ep2008
Stage: Design decision needed | Has_patch: 1
Needs_docs: 0 | Needs_tests: 0
Needs_better_patch: 0 |
---------------------------------------------+------------------------------
Changes (by Honza_Kral):

* keywords: nfa-someday list_filter filterspec nfa-changelist => nfa-
someday list_filter filterspec nfa-changelist
ep2008

--
Ticket URL: <http://code.djangoproject.com/ticket/5833#comment:12>

Django Code

unread,
Jul 19, 2008, 5:42:02 PM7/19/08
to djang...@holovaty.com, django-...@googlegroups.com
#5833: [newforms-admin] Custom FilterSpecs
---------------------------------------------+------------------------------
Reporter: Honza_Kral | Owner: jkocherhans
Status: assigned | Milestone:
Component: Admin interface | Version: SVN
Resolution: | Keywords: nfa-someday list_filter filterspec nfa-changelist ep2008
Stage: Design decision needed | Has_patch: 1
Needs_docs: 0 | Needs_tests: 0
Needs_better_patch: 0 |
---------------------------------------------+------------------------------
Changes (by Alex):

* version: newforms-admin => SVN

--
Ticket URL: <http://code.djangoproject.com/ticket/5833#comment:13>

Django Code

unread,
Aug 14, 2008, 11:21:13 PM8/14/08
to djang...@holovaty.com, django-...@googlegroups.com
#5833: [newforms-admin] Custom FilterSpecs
---------------------------------------------+------------------------------
Reporter: Honza_Kral | Owner: jkocherhans
Status: assigned | Milestone:
Component: Admin interface | Version: SVN
Resolution: | Keywords: nfa-someday list_filter filterspec nfa-changelist ep2008
Stage: Design decision needed | Has_patch: 1
Needs_docs: 0 | Needs_tests: 0
Needs_better_patch: 1 |
---------------------------------------------+------------------------------
Changes (by elwaywitvac <elway...@gmail.com>):

* needs_better_patch: 0 => 1

Comment:

{{{
Honza_Kral: I modified the filterspec definition to allow for users to
register their own filters in admin. The mechanism is simple - I just
reverted the order of the registry so that newly registered specs will
come first. That way if you register your own filter via
FilterSpec.register, it will be used before the default one.
}}}
I'm not sure having a reversed registry is intuitive. It certainly makes
overriding FilterSpecs simple. Except if I were to register two
FilterSpecs I would expect them to be tested the order I add them, the
same way it is done in the rest of Django. Maybe the FilterSpec's should
be in a Priority Queue instead of a Queue?

I had created a solution which doesn't reverse the registry ticket:8330.
But I'm realizing now that this wouldn't allow for overriding other
filters like Boolean. I'll keep playing.

--
Ticket URL: <http://code.djangoproject.com/ticket/5833#comment:14>

Django Code

unread,
Aug 14, 2008, 11:45:48 PM8/14/08
to djang...@holovaty.com, django-...@googlegroups.com
#5833: [newforms-admin] Custom FilterSpecs
---------------------------------------------+------------------------------
Reporter: Honza_Kral | Owner: jkocherhans
Status: assigned | Milestone:
Component: Admin interface | Version: SVN
Resolution: | Keywords: nfa-someday list_filter filterspec nfa-changelist ep2008
Stage: Design decision needed | Has_patch: 1
Needs_docs: 0 | Needs_tests: 0
Needs_better_patch: 1 |
---------------------------------------------+------------------------------
Comment (by elwaywitvac <elway...@gmail.com>):

Suggestion: make FieldFilterSpec's similar to how widgets work in
newforms admin.

--
Ticket URL: <http://code.djangoproject.com/ticket/5833#comment:15>

Django Code

unread,
Aug 20, 2008, 5:07:27 PM8/20/08
to djang...@holovaty.com, django-...@googlegroups.com
#5833: [newforms-admin] Custom FilterSpecs
---------------------------------------------+------------------------------
Reporter: Honza_Kral | Owner: jkocherhans
Status: assigned | Milestone:
Component: Admin interface | Version: SVN
Resolution: | Keywords: nfa-someday list_filter filterspec nfa-changelist ep2008
Stage: Design decision needed | Has_patch: 1
Needs_docs: 0 | Needs_tests: 0
Needs_better_patch: 1 |
---------------------------------------------+------------------------------
Changes (by Guilherme M. Gondim <sem...@taurinus.org>):

* cc: sem...@taurinus.org (added)

--
Ticket URL: <http://code.djangoproject.com/ticket/5833#comment:16>

Django Code

unread,
Aug 21, 2008, 12:05:27 PM8/21/08
to djang...@holovaty.com, django-...@googlegroups.com
#5833: [newforms-admin] Custom FilterSpecs
---------------------------------------------+------------------------------
Reporter: Honza_Kral | Owner: jkocherhans
Status: assigned | Milestone:
Component: Admin interface | Version: SVN
Resolution: | Keywords: nfa-someday list_filter filterspec nfa-changelist ep2008
Stage: Design decision needed | Has_patch: 1
Needs_docs: 0 | Needs_tests: 0
Needs_better_patch: 1 |
---------------------------------------------+------------------------------
Changes (by korpios):

* cc: kor...@korpios.com (removed)

--
Ticket URL: <http://code.djangoproject.com/ticket/5833#comment:17>

Django Code

unread,
Sep 5, 2008, 3:57:04 AM9/5/08
to djang...@holovaty.com, django-...@googlegroups.com
#5833: [newforms-admin] Custom FilterSpecs
---------------------------------------------+------------------------------
Reporter: Honza_Kral | Owner: jkocherhans
Status: assigned | Milestone:
Component: Admin interface | Version: SVN
Resolution: | Keywords: nfa-someday list_filter filterspec nfa-changelist ep2008
Stage: Design decision needed | Has_patch: 1
Needs_docs: 0 | Needs_tests: 0
Needs_better_patch: 1 |
---------------------------------------------+------------------------------
Changes (by anonymous):

* cc: and...@pelme.se (added)

--
Ticket URL: <http://code.djangoproject.com/ticket/5833#comment:18>

Django

unread,
Sep 17, 2008, 11:24:11 AM9/17/08
to djang...@holovaty.com, django-...@googlegroups.com
#5833: [newforms-admin] Custom FilterSpecs
---------------------------------------------+------------------------------
Reporter: Honza_Kral | Owner: jkocherhans
Status: assigned | Milestone:
Component: django.contrib.admin | Version: SVN
Resolution: | Keywords: nfa-someday list_filter filterspec nfa-changelist ep2008
Stage: Design decision needed | Has_patch: 1
Needs_docs: 0 | Needs_tests: 0
Needs_better_patch: 1 |
---------------------------------------------+------------------------------
Changes (by fas):

* cc: mbe...@gmail.com (added)

--
Ticket URL: <http://code.djangoproject.com/ticket/5833#comment:19>
Django <http://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Sep 17, 2008, 11:43:39 AM9/17/08
to djang...@holovaty.com, django-...@googlegroups.com
#5833: [newforms-admin] Custom FilterSpecs
---------------------------------------------+------------------------------
Reporter: Honza_Kral | Owner: jkocherhans
Status: assigned | Milestone:
Component: django.contrib.admin | Version: SVN
Resolution: | Keywords: nfa-someday list_filter filterspec nfa-changelist ep2008
Stage: Design decision needed | Has_patch: 1
Needs_docs: 0 | Needs_tests: 0
Needs_better_patch: 1 |
---------------------------------------------+------------------------------
Comment (by fas):

Based on korpios' idea I made a patch that takes the idea further. With
korpios' current solution you can add custom filters but not play with the
queryset. Filters only based on field lookups is too little for complex
administrations.

I provide a patch which lets you add, like korpios' suggested, custom
filters like this:

{{{
list_filter = (
'field1',
('field2', SomeFieldFilterSpec),
SomeFilterSpec,
)
}}}

Furthermore, every FilterSpec can implement get_query_set:
{{{
def SomeFilterSpec:
def get_query_set(self, cl, qs):
if self.params.has_key("custom_get_parameter"):
return qs.filter(somefield__startswith =
self.params["custom_get_parameter"])
}}}

Note that this is a trivial example that can also be achieved with field
lookup parameters. But there are no limits of how to filter the result
set.

--
Ticket URL: <http://code.djangoproject.com/ticket/5833#comment:20>

Django

unread,
Sep 23, 2008, 4:57:40 AM9/23/08
to djang...@holovaty.com, django-...@googlegroups.com
#5833: [newforms-admin] Custom FilterSpecs
---------------------------------------------+------------------------------
Reporter: Honza_Kral | Owner: jkocherhans
Status: assigned | Milestone:
Component: django.contrib.admin | Version: SVN
Resolution: | Keywords: nfa-someday list_filter filterspec nfa-changelist ep2008
Stage: Design decision needed | Has_patch: 1
Needs_docs: 0 | Needs_tests: 0
Needs_better_patch: 1 |
---------------------------------------------+------------------------------
Changes (by yuejie):

* cc: cheny...@gmail.com (added)

--
Ticket URL: <http://code.djangoproject.com/ticket/5833#comment:21>

Django

unread,
Oct 8, 2008, 8:56:35 PM10/8/08
to djang...@holovaty.com, django-...@googlegroups.com
#5833: [newforms-admin] Custom FilterSpecs
---------------------------------------------+------------------------------
Reporter: Honza_Kral | Owner: jkocherhans
Status: assigned | Milestone:
Component: django.contrib.admin | Version: SVN
Resolution: | Keywords: nfa-someday list_filter filterspec nfa-changelist ep2008
Stage: Design decision needed | Has_patch: 1
Needs_docs: 0 | Needs_tests: 0
Needs_better_patch: 1 |
---------------------------------------------+------------------------------
Changes (by anonymous):

* cc: bped...@gmail.com (added)

--
Ticket URL: <http://code.djangoproject.com/ticket/5833#comment:22>

Django

unread,
Oct 8, 2008, 9:08:44 PM10/8/08
to djang...@holovaty.com, django-...@googlegroups.com
#5833: [newforms-admin] Custom FilterSpecs
---------------------------------------------+------------------------------
Reporter: Honza_Kral | Owner: jkocherhans
Status: assigned | Milestone:
Component: django.contrib.admin | Version: SVN
Resolution: | Keywords: nfa-someday list_filter filterspec nfa-changelist ep2008
Stage: Design decision needed | Has_patch: 1
Needs_docs: 0 | Needs_tests: 0
Needs_better_patch: 1 |
---------------------------------------------+------------------------------
Comment (by anonymous):

line 103 of filterspec_with_custom_queryset_against_1_0.diff
should read:
{{{
+ super(RelatedFilterSpec, self).__init__(request, params, model,
model_admin, f)
}}}

--
Ticket URL: <http://code.djangoproject.com/ticket/5833#comment:23>

Django

unread,
Dec 12, 2008, 10:58:25 AM12/12/08
to djang...@holovaty.com, django-...@googlegroups.com
#5833: [newforms-admin] Custom FilterSpecs
---------------------------------------------+------------------------------
Reporter: Honza_Kral | Owner: jkocherhans
Status: assigned | Milestone:
Component: django.contrib.admin | Version: SVN
Resolution: | Keywords: nfa-someday list_filter filterspec nfa-changelist ep2008
Stage: Design decision needed | Has_patch: 1
Needs_docs: 0 | Needs_tests: 0
Needs_better_patch: 1 |
---------------------------------------------+------------------------------
Changes (by gerdemb):

* cc: django...@ibeni.net (added)

Comment:

I believe there is a small bug with this patch. Line 31 of
filterspec_with_custom_queryset_against_1_0.diff should be indented once
more so that get_field() is only called when a field is defined in the
list_filter. In the case that the list_filter item is a single callable
item, the field variable is not set and get_field() should not be called
for verification.

Also, any word on if this feature will make it into 1.1? I notice that
there is no implemented listed on the status page. I'm using this feature
frequently in my application, and would prefer to run a released version
of Django instead of patching. :)

--
Ticket URL: <http://code.djangoproject.com/ticket/5833#comment:24>

Django

unread,
Dec 12, 2008, 7:02:05 PM12/12/08
to djang...@holovaty.com, django-...@googlegroups.com
#5833: [newforms-admin] Custom FilterSpecs
---------------------------------------------+------------------------------
Reporter: Honza_Kral | Owner: jkocherhans
Status: assigned | Milestone:
Component: django.contrib.admin | Version: SVN
Resolution: | Keywords: nfa-someday list_filter filterspec nfa-changelist ep2008
Stage: Design decision needed | Has_patch: 1
Needs_docs: 0 | Needs_tests: 0
Needs_better_patch: 1 |
---------------------------------------------+------------------------------
Changes (by niels):

* cc: niels...@gmail.com (added)

--
Ticket URL: <http://code.djangoproject.com/ticket/5833#comment:25>

Django

unread,
Dec 14, 2008, 4:29:33 PM12/14/08
to djang...@holovaty.com, django-...@googlegroups.com
#5833: [newforms-admin] Custom FilterSpecs
---------------------------------------------+------------------------------
Reporter: Honza_Kral | Owner: jkocherhans
Status: assigned | Milestone:
Component: django.contrib.admin | Version: SVN
Resolution: | Keywords: nfa-someday list_filter filterspec nfa-changelist ep2008
Stage: Design decision needed | Has_patch: 1
Needs_docs: 0 | Needs_tests: 0
Needs_better_patch: 1 |
---------------------------------------------+------------------------------
Changes (by xtrqt):

* cc: jan.rz...@gmail.com (added)

--
Ticket URL: <http://code.djangoproject.com/ticket/5833#comment:26>

Django

unread,
Jan 22, 2009, 7:17:30 AM1/22/09
to djang...@holovaty.com, django-...@googlegroups.com
#5833: [newforms-admin] Custom FilterSpecs
---------------------------------------------+------------------------------
Reporter: Honza_Kral | Owner: jkocherhans
Status: assigned | Milestone:
Component: django.contrib.admin | Version: SVN
Resolution: | Keywords: nfa-someday list_filter filterspec nfa-changelist ep2008
Stage: Design decision needed | Has_patch: 1
Needs_docs: 0 | Needs_tests: 0
Needs_better_patch: 1 |
---------------------------------------------+------------------------------
Comment (by gerdemb):

New path is diff versus v1.0.2 of django and includes fixes mentioned in
the following comments:

10/08/08 20:08:44 changed by anonymous ¶
12/12/08 09:58:24 changed by gerdemb ¶

--
Ticket URL: <http://code.djangoproject.com/ticket/5833#comment:27>

Django

unread,
Feb 6, 2009, 9:58:56 PM2/6/09
to djang...@holovaty.com, django-...@googlegroups.com
#5833: [newforms-admin] Custom FilterSpecs
---------------------------------------------+------------------------------
Reporter: Honza_Kral | Owner: jkocherhans
Status: assigned | Milestone:
Component: django.contrib.admin | Version: SVN
Resolution: | Keywords: nfa-someday list_filter filterspec nfa-changelist ep2008
Stage: Design decision needed | Has_patch: 1
Needs_docs: 0 | Needs_tests: 0
Needs_better_patch: 1 |
---------------------------------------------+------------------------------
Changes (by kmike):

* cc: kmi...@gmail.com (added)

--
Ticket URL: <http://code.djangoproject.com/ticket/5833#comment:28>

Django

unread,
Feb 8, 2009, 10:29:40 AM2/8/09
to djang...@holovaty.com, django-...@googlegroups.com
#5833: [newforms-admin] Custom FilterSpecs
---------------------------------------------+------------------------------
Reporter: Honza_Kral | Owner: jkocherhans
Status: assigned | Milestone:
Component: django.contrib.admin | Version: SVN
Resolution: | Keywords: nfa-someday list_filter filterspec nfa-changelist ep2008
Stage: Design decision needed | Has_patch: 1
Needs_docs: 0 | Needs_tests: 0
Needs_better_patch: 1 |
---------------------------------------------+------------------------------
Comment (by gerdemb):

I updated the patch to the latest HEAD and fixed the TODO comments. In
order to pass the existing tests, I had to disable the use of custom GET
params. In the original patch, the filterspec could consume a custom param
and then return an arbitrary queryset based on this parameter, but to do
this it silently removed the parameters that don't match a field name from
the request. The problem is that there is a test to insure that any
parameters that do not match field names are handled by forwarding to ?e=1
(testIncorrectLookupParameters) which failed when the previous patch
silently removed them. Additionally, the code in the previous patch didn't
handle filters on M2M relationships through an intermediate table because
it assumed the first part of the search param would be a field name.

--
Ticket URL: <http://code.djangoproject.com/ticket/5833#comment:29>

Django

unread,
Feb 8, 2009, 1:06:12 PM2/8/09
to djang...@holovaty.com, django-...@googlegroups.com
#5833: [newforms-admin] Custom FilterSpecs
---------------------------------------------+------------------------------
Reporter: Honza_Kral | Owner: jkocherhans
Status: assigned | Milestone:
Component: django.contrib.admin | Version: SVN
Resolution: | Keywords: nfa-someday list_filter filterspec nfa-changelist ep2008
Stage: Design decision needed | Has_patch: 1
Needs_docs: 0 | Needs_tests: 0
Needs_better_patch: 1 |
---------------------------------------------+------------------------------
Comment (by gerdemb):

Developer discussion here: http://groups.google.com/group/django-
developers/browse_thread/thread/eb08729417d50ef3

--
Ticket URL: <http://code.djangoproject.com/ticket/5833#comment:30>

Django

unread,
Feb 16, 2009, 1:19:34 PM2/16/09
to djang...@holovaty.com, django-...@googlegroups.com
#5833: [newforms-admin] Custom FilterSpecs
-------------------------------------------+--------------------------------
Reporter: Honza_Kral | Owner: jkocherhans
Status: assigned | Milestone:
Component: django.contrib.admin | Version: SVN
Resolution: | Keywords: nfa-someday list_filter filterspec nfa-changelist ep2008
Stage: Accepted | Has_patch: 1
Needs_docs: 0 | Needs_tests: 1
Needs_better_patch: 0 |
-------------------------------------------+--------------------------------
Changes (by ean...@gmail.com):

* cc: ean...@gmail.com (added)
* needs_better_patch: 1 => 0
* needs_tests: 0 => 1
* stage: Design decision needed => Accepted

Comment:

I am attaching a new patch against the latest HEAD. It's based on
gerdemb's patch but now allows for consuming of GET parameters to allow
for custom, non-field based querystring keys. The patch also implements a
priority queue in a sense; FieldFilterSpec.register() allows you to pass
in high_priority=True in order to register the FieldFilterSpec as high
priority. This argument is True by default but passed in as False for all
default filter specs. High priority specs are inserted before normal
priority specs, but order is preserved amongst the two separate groups.
Let me know what you think of that solution.

I'm also moving this to Accepted since it's on the 1.1 features list
(forgive me if this is an incorrect decision). Also flagging it as Needs
tests.

--
Ticket URL: <http://code.djangoproject.com/ticket/5833#comment:31>

Django

unread,
Feb 16, 2009, 1:23:57 PM2/16/09
to djang...@holovaty.com, django-...@googlegroups.com
#5833: [newforms-admin] Custom FilterSpecs
-------------------------------------------+--------------------------------
Reporter: Honza_Kral | Owner: jkocherhans
Status: assigned | Milestone:
Component: django.contrib.admin | Version: SVN
Resolution: | Keywords: nfa-someday list_filter filterspec nfa-changelist ep2008
Stage: Accepted | Has_patch: 1
Needs_docs: 0 | Needs_tests: 1
Needs_better_patch: 0 |
-------------------------------------------+--------------------------------
Comment (by ean...@gmail.com):

Please see 5833-against-9836-new-proper.patch and not
5833-against-9836-new.patch; I accidently diffed some additional,
unrelated changes, and couldn't get trac to replace the old attachment.

--
Ticket URL: <http://code.djangoproject.com/ticket/5833#comment:32>

Django

unread,
Feb 16, 2009, 1:37:28 PM2/16/09
to djang...@holovaty.com, django-...@googlegroups.com
#5833: [newforms-admin] Custom FilterSpecs
-------------------------------------------+--------------------------------
Reporter: Honza_Kral | Owner: jkocherhans
Status: assigned | Milestone:
Component: django.contrib.admin | Version: SVN
Resolution: | Keywords: nfa-someday list_filter filterspec nfa-changelist ep2008
Stage: Accepted | Has_patch: 1
Needs_docs: 0 | Needs_tests: 1
Needs_better_patch: 0 |
-------------------------------------------+--------------------------------
Comment (by kmtracey):

I deleted the 5833-against-9836-new.patch to avoid confusion.

--
Ticket URL: <http://code.djangoproject.com/ticket/5833#comment:33>

Django

unread,
Feb 16, 2009, 7:17:18 PM2/16/09
to djang...@holovaty.com, django-...@googlegroups.com
#5833: [newforms-admin] Custom FilterSpecs
-------------------------------------------+--------------------------------
Reporter: Honza_Kral | Owner: jkocherhans
Status: assigned | Milestone:
Component: django.contrib.admin | Version: SVN
Resolution: | Keywords: nfa-someday list_filter filterspec nfa-changelist ep2008
Stage: Accepted | Has_patch: 1
Needs_docs: 0 | Needs_tests: 1
Needs_better_patch: 0 |
-------------------------------------------+--------------------------------
Changes (by gonz):

* cc: gonz (added)

--
Ticket URL: <http://code.djangoproject.com/ticket/5833#comment:34>

Django

unread,
Feb 17, 2009, 5:51:35 AM2/17/09
to djang...@holovaty.com, django-...@googlegroups.com
#5833: [newforms-admin] Custom FilterSpecs
-------------------------------------------+--------------------------------
Reporter: Honza_Kral | Owner: jkocherhans
Status: assigned | Milestone:
Component: django.contrib.admin | Version: SVN
Resolution: | Keywords: nfa-someday list_filter filterspec nfa-changelist ep2008
Stage: Accepted | Has_patch: 1
Needs_docs: 0 | Needs_tests: 1
Needs_better_patch: 0 |
-------------------------------------------+--------------------------------
Changes (by niels):

* cc: niels...@gmail.com (removed)

--
Ticket URL: <http://code.djangoproject.com/ticket/5833#comment:35>

Django

unread,
Feb 28, 2009, 2:45:02 PM2/28/09
to djang...@holovaty.com, django-...@googlegroups.com
#5833: [newforms-admin] Custom FilterSpecs
-------------------------------------------+--------------------------------
Reporter: Honza_Kral | Owner: jkocherhans
Status: assigned | Milestone: 1.1 beta
Component: django.contrib.admin | Version: SVN
Resolution: | Keywords: nfa-someday list_filter filterspec nfa-changelist ep2008
Stage: Accepted | Has_patch: 1
Needs_docs: 0 | Needs_tests: 1
Needs_better_patch: 0 |
-------------------------------------------+--------------------------------
Changes (by jacob):

* milestone: => 1.1 beta

--
Ticket URL: <http://code.djangoproject.com/ticket/5833#comment:36>

Django

unread,
Mar 19, 2009, 7:13:38 PM3/19/09
to djang...@holovaty.com, django-...@googlegroups.com
#5833: [newforms-admin] Custom FilterSpecs
-------------------------------------------+--------------------------------
Reporter: Honza_Kral | Owner: jkocherhans
Status: assigned | Milestone: 1.1 beta
Component: django.contrib.admin | Version: SVN
Resolution: | Keywords: nfa-someday list_filter filterspec nfa-changelist ep2008
Stage: Accepted | Has_patch: 1
Needs_docs: 0 | Needs_tests: 1
Needs_better_patch: 0 |
-------------------------------------------+--------------------------------
Changes (by anonymous):

* cc: cia...@mbnet.fi (added)

--
Ticket URL: <http://code.djangoproject.com/ticket/5833#comment:37>

Django

unread,
Mar 20, 2009, 8:14:39 AM3/20/09
to djang...@holovaty.com, django-...@googlegroups.com
#5833: [newforms-admin] Custom FilterSpecs
-------------------------------------------+--------------------------------
Reporter: Honza_Kral | Owner: jkocherhans
Status: assigned | Milestone: 1.1 beta
Component: django.contrib.admin | Version: SVN
Resolution: | Keywords: nfa-someday list_filter filterspec nfa-changelist ep2008
Stage: Accepted | Has_patch: 1
Needs_docs: 0 | Needs_tests: 1
Needs_better_patch: 0 |
-------------------------------------------+--------------------------------
Changes (by rvdrijst):

* cc: rvdrijst (added)

--
Ticket URL: <http://code.djangoproject.com/ticket/5833#comment:38>

Django

unread,
Mar 21, 2009, 7:33:10 PM3/21/09
to djang...@holovaty.com, django-...@googlegroups.com
#5833: Custom FilterSpecs
-------------------------------------------+--------------------------------
Reporter: Honza_Kral | Owner: jkocherhans
Status: assigned | Milestone: 1.1 beta
Component: django.contrib.admin | Version: SVN
Resolution: | Keywords: nfa-someday list_filter filterspec nfa-changelist ep2008
Stage: Accepted | Has_patch: 1
Needs_docs: 1 | Needs_tests: 1
Needs_better_patch: 0 |
-------------------------------------------+--------------------------------
Changes (by kmtracey):

* needs_docs: 0 => 1
* summary: [newforms-admin] Custom FilterSpecs => Custom FilterSpecs

Comment:

I don't see any documentation for this enhancement in any of the patches?
Makes it hard to gets started on reviewing the code. In the absence of
doc, tests would also at least show how the new function is intended to be
used, but those too are still missing. If anyone who has worked on the
patches here or has an interest in seeing this done could provide some of
these missing pieces, that would help move this one along.

--
Ticket URL: <http://code.djangoproject.com/ticket/5833#comment:39>

Django

unread,
Mar 22, 2009, 10:27:01 PM3/22/09
to djang...@holovaty.com, django-...@googlegroups.com
#5833: Custom FilterSpecs
-------------------------------------------+--------------------------------
Reporter: Honza_Kral | Owner: jkocherhans
Status: assigned | Milestone:
Component: django.contrib.admin | Version: SVN
Resolution: | Keywords: nfa-someday list_filter filterspec nfa-changelist ep2008
Stage: Accepted | Has_patch: 1
Needs_docs: 1 | Needs_tests: 1
Needs_better_patch: 0 |
-------------------------------------------+--------------------------------
Changes (by jacob):

* milestone: 1.1 beta =>

Comment:

Without docs and tests, and with 1.1 feature freeze coming up soon, this
isn't going to make 1.1.

--
Ticket URL: <http://code.djangoproject.com/ticket/5833#comment:40>

Django

unread,
Mar 22, 2009, 11:18:19 PM3/22/09
to djang...@holovaty.com, django-...@googlegroups.com
#5833: Custom FilterSpecs
-------------------------------------------+--------------------------------
Reporter: Honza_Kral | Owner: jkocherhans
Status: assigned | Milestone:
Component: django.contrib.admin | Version: SVN
Resolution: | Keywords: nfa-someday list_filter filterspec nfa-changelist ep2008
Stage: Accepted | Has_patch: 1
Needs_docs: 1 | Needs_tests: 1
Needs_better_patch: 0 |
-------------------------------------------+--------------------------------
Comment (by Honza_Kral):

Replying to [comment:40 jacob]:
> Without docs and tests, and with 1.1 feature freeze coming up soon, this
isn't going to make 1.1.

I would like to get this committed, we can work on it during the PyCON
sprint. It is really important for us that this ticket or #3400 gets into
1.1 and we are ready to put some work into it.

--
Ticket URL: <http://code.djangoproject.com/ticket/5833#comment:41>

Django

unread,
Mar 23, 2009, 12:43:36 AM3/23/09
to djang...@holovaty.com, django-...@googlegroups.com
#5833: Custom FilterSpecs
-------------------------------------------+--------------------------------
Reporter: Honza_Kral | Owner: jkocherhans
Status: assigned | Milestone:
Component: django.contrib.admin | Version: SVN
Resolution: | Keywords: nfa-someday list_filter filterspec nfa-changelist ep2008
Stage: Accepted | Has_patch: 1
Needs_docs: 1 | Needs_tests: 1
Needs_better_patch: 0 |
-------------------------------------------+--------------------------------
Comment (by brosner):

The feature freeze is tomorrow. Only bug fixes will be happening during
the sprints at PyCon. I'm afraid this is just going to have to wait until
1.2.

--
Ticket URL: <http://code.djangoproject.com/ticket/5833#comment:42>

Django

unread,
Mar 31, 2009, 7:29:37 AM3/31/09
to djang...@holovaty.com, django-...@googlegroups.com
#5833: Custom FilterSpecs
-------------------------------------------+--------------------------------
Reporter: Honza_Kral | Owner: jkocherhans
Status: assigned | Milestone: 1.2
Component: django.contrib.admin | Version: SVN
Resolution: | Keywords: nfa-someday list_filter filterspec nfa-changelist ep2008
Stage: Accepted | Has_patch: 1
Needs_docs: 1 | Needs_tests: 1
Needs_better_patch: 0 |
-------------------------------------------+--------------------------------
Changes (by mrts):

* milestone: => 1.2

Comment:

Re-targeting for 1.2.

--
Ticket URL: <http://code.djangoproject.com/ticket/5833#comment:43>

Django

unread,
Jul 17, 2009, 5:55:06 PM7/17/09
to djang...@holovaty.com, django-...@googlegroups.com
#5833: Custom FilterSpecs
-------------------------------------------+--------------------------------
Reporter: Honza_Kral | Owner: jkocherhans
Status: assigned | Milestone: 1.2
Component: django.contrib.admin | Version: SVN
Resolution: | Keywords: nfa-someday list_filter filterspec nfa-changelist ep2008
Stage: Accepted | Has_patch: 1
Needs_docs: 1 | Needs_tests: 1
Needs_better_patch: 0 |
-------------------------------------------+--------------------------------
Changes (by eppsilon):

* cc: eppsilon (added)

--
Ticket URL: <http://code.djangoproject.com/ticket/5833#comment:44>

Django

unread,
Jul 20, 2009, 5:57:13 AM7/20/09
to djang...@holovaty.com, django-...@googlegroups.com
#5833: Custom FilterSpecs
-------------------------------------------+--------------------------------
Reporter: Honza_Kral | Owner: jkocherhans
Status: assigned | Milestone: 1.2
Component: django.contrib.admin | Version: SVN
Resolution: | Keywords: nfa-someday list_filter filterspec nfa-changelist ep2008
Stage: Accepted | Has_patch: 1
Needs_docs: 1 | Needs_tests: 1
Needs_better_patch: 0 |
-------------------------------------------+--------------------------------
Changes (by anonymous):

* cc: ram...@gmail.com (added)

--
Ticket URL: <http://code.djangoproject.com/ticket/5833#comment:45>

Django

unread,
Aug 3, 2009, 2:28:38 PM8/3/09
to djang...@holovaty.com, django-...@googlegroups.com
#5833: Custom FilterSpecs
-------------------------------------------+--------------------------------
Reporter: Honza_Kral | Owner: jkocherhans
Status: assigned | Milestone: 1.2
Component: django.contrib.admin | Version: SVN
Resolution: | Keywords: nfa-someday list_filter filterspec nfa-changelist ep2008
Stage: Accepted | Has_patch: 1
Needs_docs: 1 | Needs_tests: 1
Needs_better_patch: 0 |
-------------------------------------------+--------------------------------
Changes (by anonymous):

* cc: pei...@ya.ru (added)

--
Ticket URL: <http://code.djangoproject.com/ticket/5833#comment:46>

Django

unread,
Aug 20, 2009, 7:42:16 AM8/20/09
to djang...@holovaty.com, django-...@googlegroups.com
#5833: Custom FilterSpecs
-------------------------------------------+--------------------------------
Reporter: Honza_Kral | Owner: jkocherhans
Status: assigned | Milestone: 1.2
Component: django.contrib.admin | Version: SVN
Resolution: | Keywords: nfa-someday list_filter filterspec nfa-changelist ep2008
Stage: Accepted | Has_patch: 1
Needs_docs: 1 | Needs_tests: 1
Needs_better_patch: 0 |
-------------------------------------------+--------------------------------
Changes (by marcob):

* cc: marc...@gmail.com (added)

--
Ticket URL: <http://code.djangoproject.com/ticket/5833#comment:47>

Django

unread,
Aug 21, 2009, 10:48:17 AM8/21/09
to djang...@holovaty.com, django-...@googlegroups.com
#5833: Custom FilterSpecs
-------------------------------------------+--------------------------------
Reporter: Honza_Kral | Owner: jkocherhans
Status: assigned | Milestone: 1.2
Component: django.contrib.admin | Version: SVN
Resolution: | Keywords: nfa-someday list_filter filterspec nfa-changelist ep2008
Stage: Accepted | Has_patch: 1
Needs_docs: 1 | Needs_tests: 1
Needs_better_patch: 0 |
-------------------------------------------+--------------------------------
Changes (by anonymous):

* cc: da...@reynoldsfamily.org.uk (added)

--
Ticket URL: <http://code.djangoproject.com/ticket/5833#comment:48>

Django

unread,
Aug 22, 2009, 11:55:45 PM8/22/09
to djang...@holovaty.com, django-...@googlegroups.com
#5833: Custom FilterSpecs
-------------------------------------------+--------------------------------
Reporter: Honza_Kral | Owner: jkocherhans
Status: assigned | Milestone: 1.2
Component: django.contrib.admin | Version: SVN
Resolution: | Keywords: nfa-someday list_filter filterspec nfa-changelist ep2008
Stage: Accepted | Has_patch: 1
Needs_docs: 1 | Needs_tests: 1
Needs_better_patch: 0 |
-------------------------------------------+--------------------------------
Changes (by anonymous):

* cc: sciy...@gmail.com (added)

--
Ticket URL: <http://code.djangoproject.com/ticket/5833#comment:49>

Django

unread,
Aug 23, 2009, 1:04:38 AM8/23/09
to djang...@holovaty.com, django-...@googlegroups.com
#5833: Custom FilterSpecs
-------------------------------------------+--------------------------------
Reporter: Honza_Kral | Owner: jkocherhans
Status: assigned | Milestone: 1.2
Component: django.contrib.admin | Version: SVN
Resolution: | Keywords: nfa-someday list_filter filterspec nfa-changelist ep2008
Stage: Accepted | Has_patch: 1
Needs_docs: 1 | Needs_tests: 1
Needs_better_patch: 0 |
-------------------------------------------+--------------------------------
Comment (by sciyoshi):

The validation in the latest patch is broken. Attaching a new version
against 1.1/SVN which also fixes #11771.

--
Ticket URL: <http://code.djangoproject.com/ticket/5833#comment:50>

Django

unread,
Aug 23, 2009, 3:52:25 AM8/23/09
to djang...@holovaty.com, django-...@googlegroups.com
#5833: Custom FilterSpecs
-------------------------------------------+--------------------------------
Reporter: Honza_Kral | Owner: jkocherhans
Status: assigned | Milestone: 1.2
Component: django.contrib.admin | Version: SVN
Resolution: | Keywords: nfa-someday list_filter filterspec nfa-changelist ep2008
Stage: Accepted | Has_patch: 1
Needs_docs: 1 | Needs_tests: 1
Needs_better_patch: 0 |
-------------------------------------------+--------------------------------
Comment (by marcob):

When you delete a record, querystring looses return_to_ parameter.

(BTW last patch seems not working for me)

--
Ticket URL: <http://code.djangoproject.com/ticket/5833#comment:51>

Django

unread,
Aug 25, 2009, 9:15:21 PM8/25/09
to djang...@holovaty.com, django-...@googlegroups.com
#5833: Custom FilterSpecs
-------------------------------------------+--------------------------------
Reporter: Honza_Kral | Owner: jkocherhans
Status: assigned | Milestone: 1.2
Component: django.contrib.admin | Version: SVN
Resolution: | Keywords: nfa-someday list_filter filterspec nfa-changelist ep2008
Stage: Accepted | Has_patch: 1
Needs_docs: 1 | Needs_tests: 1
Needs_better_patch: 0 |
-------------------------------------------+--------------------------------
Comment (by anonymous):

Another place where it would be likeable to keep the filters are with
admin actions

--
Ticket URL: <http://code.djangoproject.com/ticket/5833#comment:52>

Django

unread,
Oct 5, 2009, 5:14:30 PM10/5/09
to djang...@holovaty.com, django-...@googlegroups.com
#5833: Custom FilterSpecs
-------------------------------------------+--------------------------------
Reporter: Honza_Kral | Owner: jkocherhans
Status: assigned | Milestone: 1.2
Component: django.contrib.admin | Version: SVN
Resolution: | Keywords: nfa-someday list_filter filterspec nfa-changelist ep2008
Stage: Accepted | Has_patch: 1
Needs_docs: 1 | Needs_tests: 1
Needs_better_patch: 0 |
-------------------------------------------+--------------------------------
Changes (by velmont):

* cc: velmont (added)

--
Ticket URL: <http://code.djangoproject.com/ticket/5833#comment:53>

Django

unread,
Oct 6, 2009, 9:29:05 AM10/6/09
to djang...@holovaty.com, django-...@googlegroups.com
#5833: Custom FilterSpecs
-------------------------------------------+--------------------------------
Reporter: Honza_Kral | Owner: jkocherhans
Status: assigned | Milestone: 1.2
Component: django.contrib.admin | Version: SVN
Resolution: | Keywords: nfa-someday list_filter filterspec nfa-changelist ep2008
Stage: Accepted | Has_patch: 1
Needs_docs: 1 | Needs_tests: 1
Needs_better_patch: 0 |
-------------------------------------------+--------------------------------
Changes (by anonymous):

* cc: seanl (added)

--
Ticket URL: <http://code.djangoproject.com/ticket/5833#comment:54>

Django

unread,
Nov 28, 2009, 2:24:15 PM11/28/09
to djang...@holovaty.com, django-...@googlegroups.com
#5833: Custom FilterSpecs
-------------------------------------------+--------------------------------
Reporter: Honza_Kral | Owner: jkocherhans
Status: assigned | Milestone: 1.2
Component: django.contrib.admin | Version: SVN
Resolution: | Keywords: nfa-someday list_filter filterspec nfa-changelist ep2008
Stage: Accepted | Has_patch: 1
Needs_docs: 1 | Needs_tests: 1
Needs_better_patch: 0 |
-------------------------------------------+--------------------------------
--
Ticket URL: <http://code.djangoproject.com/ticket/5833#comment:55>

Django

unread,
Dec 9, 2009, 5:17:30 PM12/9/09
to djang...@holovaty.com, django-...@googlegroups.com
#5833: Custom FilterSpecs
-------------------------------------------+--------------------------------
Reporter: Honza_Kral | Owner: jkocherhans
Status: assigned | Milestone: 1.2
Component: django.contrib.admin | Version: SVN
Resolution: | Keywords: nfa-someday list_filter filterspec nfa-changelist ep2008
Stage: Accepted | Has_patch: 1
Needs_docs: 1 | Needs_tests: 1
Needs_better_patch: 0 |
-------------------------------------------+--------------------------------
Changes (by alexkoshelev):

* cc: alexkoshelev (added)

--
Ticket URL: <http://code.djangoproject.com/ticket/5833#comment:56>

Django

unread,
Jan 5, 2010, 6:14:54 AM1/5/10
to djang...@holovaty.com, django-...@googlegroups.com
#5833: Custom FilterSpecs
-------------------------------------------+--------------------------------
Reporter: Honza_Kral | Owner: jkocherhans
Status: assigned | Milestone: 1.2
Component: django.contrib.admin | Version: SVN
Resolution: | Keywords: nfa-someday list_filter filterspec nfa-changelist ep2008
Stage: Accepted | Has_patch: 1
Needs_docs: 1 | Needs_tests: 1
Needs_better_patch: 0 |
-------------------------------------------+--------------------------------
Changes (by marinho):

* cc: marinho (added)

--
Ticket URL: <http://code.djangoproject.com/ticket/5833#comment:57>

Django

unread,
Jan 14, 2010, 6:34:31 AM1/14/10
to djang...@holovaty.com, django-...@googlegroups.com
#5833: Custom FilterSpecs
-------------------------------------------+--------------------------------
Reporter: Honza_Kral | Owner: jkocherhans
Status: assigned | Milestone: 1.2
Component: django.contrib.admin | Version: SVN
Resolution: | Keywords: nfa-someday list_filter filterspec nfa-changelist ep2008
Stage: Accepted | Has_patch: 1
Needs_docs: 1 | Needs_tests: 1
Needs_better_patch: 0 |
-------------------------------------------+--------------------------------
Changes (by danfairs):

* cc: danfairs (added)

--
Ticket URL: <http://code.djangoproject.com/ticket/5833#comment:58>

Django

unread,
Jan 28, 2010, 9:13:51 AM1/28/10
to djang...@holovaty.com, django-...@googlegroups.com
#5833: Custom FilterSpecs
-------------------------------------------+--------------------------------
Reporter: Honza_Kral | Owner: jkocherhans
Status: assigned | Milestone: 1.2
Component: django.contrib.admin | Version: SVN
Resolution: | Keywords: nfa-someday list_filter filterspec nfa-changelist ep2008
Stage: Accepted | Has_patch: 1
Needs_docs: 1 | Needs_tests: 1
Needs_better_patch: 0 |
-------------------------------------------+--------------------------------
Comment (by vrehak):

Just a small note: the patch 5883.patch should be modified in
django/contrib/admin/views/main.py, line 200.

Currently it reads:

{{{
if new_qs:
}}}

which fails if new_qs is empty QuerySet (i.e. the filters output is
empty). It works for me if I change it to

{{{
if new_qs is not False:
}}}

--
Ticket URL: <http://code.djangoproject.com/ticket/5833#comment:59>

Django

unread,
Feb 5, 2010, 8:38:21 AM2/5/10
to djang...@holovaty.com, django-...@googlegroups.com
#5833: Custom FilterSpecs
-------------------------------------------+--------------------------------
Reporter: Honza_Kral | Owner: jkocherhans
Status: assigned | Milestone: 1.2
Component: django.contrib.admin | Version: SVN
Resolution: | Keywords: nfa-someday list_filter filterspec nfa-changelist ep2008
Stage: Accepted | Has_patch: 1
Needs_docs: 1 | Needs_tests: 1
Needs_better_patch: 0 |
-------------------------------------------+--------------------------------
Comment (by russellm):

#12173 raised the issue of ORs in filterspecs.

--
Ticket URL: <http://code.djangoproject.com/ticket/5833#comment:60>

Django

unread,
Feb 21, 2010, 6:54:34 AM2/21/10
to djang...@holovaty.com, django-...@googlegroups.com
#5833: Custom FilterSpecs
-------------------------------------------+--------------------------------
Reporter: Honza_Kral | Owner: jkocherhans
Status: assigned | Milestone: 1.2
Component: django.contrib.admin | Version: SVN
Resolution: | Keywords: nfa-someday list_filter filterspec nfa-changelist ep2008
Stage: Accepted | Has_patch: 1
Needs_docs: 1 | Needs_tests: 1
Needs_better_patch: 0 |
-------------------------------------------+--------------------------------
Changes (by anonymous):

* cc: rman...@gmail.com (added)

--
Ticket URL: <http://code.djangoproject.com/ticket/5833#comment:61>

Django

unread,
Feb 23, 2010, 7:00:29 PM2/23/10
to djang...@holovaty.com, django-...@googlegroups.com
#5833: Custom FilterSpecs
-------------------------------------------+--------------------------------
Reporter: Honza_Kral | Owner: jkocherhans
Status: assigned | Milestone:
Component: django.contrib.admin | Version: SVN
Resolution: | Keywords: nfa-someday list_filter filterspec nfa-changelist ep2008
Stage: Accepted | Has_patch: 1
Needs_docs: 1 | Needs_tests: 1
Needs_better_patch: 0 |
-------------------------------------------+--------------------------------
Changes (by ubernostrum):

* milestone: 1.2 =>

Comment:

1.2 is feature-frozen, moving this feature request off the milestone.

--
Ticket URL: <http://code.djangoproject.com/ticket/5833#comment:62>

Django

unread,
Mar 12, 2010, 9:46:43 AM3/12/10
to djang...@holovaty.com, django-...@googlegroups.com
#5833: Custom FilterSpecs
-------------------------------------------+--------------------------------
Reporter: Honza_Kral | Owner: jkocherhans
Status: assigned | Milestone:
Component: django.contrib.admin | Version: SVN
Resolution: | Keywords: nfa-someday list_filter filterspec nfa-changelist ep2008
Stage: Accepted | Has_patch: 1
Needs_docs: 1 | Needs_tests: 1
Needs_better_patch: 0 |
-------------------------------------------+--------------------------------
Changes (by broderboy):

* cc: timothy...@gmail.com (added)

--
Ticket URL: <http://code.djangoproject.com/ticket/5833#comment:63>

Django

unread,
Apr 19, 2010, 11:24:32 AM4/19/10
to djang...@holovaty.com, django-...@googlegroups.com
#5833: Custom FilterSpecs
-------------------------------------------+--------------------------------
Reporter: Honza_Kral | Owner: jkocherhans
Status: assigned | Milestone:
Component: django.contrib.admin | Version: SVN
Resolution: | Keywords: nfa-someday list_filter filterspec nfa-changelist ep2008
Stage: Accepted | Has_patch: 1
Needs_docs: 1 | Needs_tests: 1
Needs_better_patch: 0 |
-------------------------------------------+--------------------------------
Changes (by manfre):

* cc: manfre (added)

--
Ticket URL: <http://code.djangoproject.com/ticket/5833#comment:64>
Django <http://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

--
You received this message because you are subscribed to the Google Groups "Django updates" group.
To post to this group, send email to django-...@googlegroups.com.
To unsubscribe from this group, send email to django-update...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-updates?hl=en.

Django

unread,
May 11, 2010, 5:16:34 AM5/11/10
to djang...@holovaty.com, django-...@googlegroups.com
#5833: Custom FilterSpecs
-------------------------------------------+--------------------------------
Reporter: Honza_Kral | Owner: jkocherhans
Status: assigned | Milestone:
Component: django.contrib.admin | Version: SVN
Resolution: | Keywords: nfa-someday list_filter filterspec nfa-changelist ep2008
Stage: Accepted | Has_patch: 1
Needs_docs: 1 | Needs_tests: 1
Needs_better_patch: 0 |
-------------------------------------------+--------------------------------
Changes (by dominicrodger):

* cc: inte...@dominicrodger.com (added)

--
Ticket URL: <http://code.djangoproject.com/ticket/5833#comment:65>

Django

unread,
Jun 27, 2010, 7:17:20 AM6/27/10
to djang...@holovaty.com, django-...@googlegroups.com
#5833: Custom FilterSpecs
-------------------------------------------+--------------------------------
Reporter: Honza_Kral | Owner: jkocherhans
Status: assigned | Milestone:
Component: django.contrib.admin | Version: SVN
Resolution: | Keywords: nfa-someday list_filter filterspec nfa-changelist ep2008
Stage: Accepted | Has_patch: 1
Needs_docs: 1 | Needs_tests: 1
Needs_better_patch: 0 |
-------------------------------------------+--------------------------------
Changes (by isometry):

* cc: isometry (added)

--
Ticket URL: <http://code.djangoproject.com/ticket/5833#comment:66>

Django

unread,
Jul 31, 2010, 8:19:39 PM7/31/10
to djang...@holovaty.com, django-...@googlegroups.com
#5833: Custom FilterSpecs
-------------------------------------------+--------------------------------
Reporter: Honza_Kral | Owner: jkocherhans
Status: assigned | Milestone:
Component: django.contrib.admin | Version: SVN
Resolution: | Keywords: nfa-someday list_filter filterspec nfa-changelist ep2008
Stage: Accepted | Has_patch: 1
Needs_docs: 1 | Needs_tests: 1
Needs_better_patch: 0 |
-------------------------------------------+--------------------------------
Changes (by bendavis78):

* cc: benda...@gmail.com (added)

--
Ticket URL: <http://code.djangoproject.com/ticket/5833#comment:67>

Django

unread,
Jul 31, 2010, 10:57:51 PM7/31/10
to djang...@holovaty.com, django-...@googlegroups.com
#5833: Custom FilterSpecs
-------------------------------------------+--------------------------------
Reporter: Honza_Kral | Owner: jkocherhans
Status: assigned | Milestone:
Component: django.contrib.admin | Version: SVN
Resolution: | Keywords: nfa-someday list_filter filterspec nfa-changelist ep2008
Stage: Accepted | Has_patch: 1
Needs_docs: 1 | Needs_tests: 1
Needs_better_patch: 0 |
-------------------------------------------+--------------------------------
Comment (by bendavis78):

It seems that the latest patch did not support using a "field-less"
filterspec. The validation was failing because it was still expecting a
field. I've attached a patch against 1.2.1 that works for me. If anyone
involved could please test this out, that would be great.

We need some docs and tests for this -- it'd be nice to see this added to
1.3. Although, it would be good to get some feedback from the core devs
to make sure this is going in the right direction.

In the meantime, here's a silly little example of how a custom non-field-
specific filterspec can be used (in case anyone wants to play around with
it).
{{{
#!python
from testapp import models
from django.contrib.admin.filterspecs import FilterSpec
from django.contrib import admin
from django.utils.datastructures import SortedDict

class HowYummyFilterSpec(FilterSpec):
def __init__(self, request, params, model, model_admin):
super(HowYummyFilterSpec, self).__init__(request, params, model,
model_admin)
self.links = SortedDict((
('All', 'all'),
('Double Rainbow', 'so_intense'),
('Pretty good', 'good'),
('Not great', 'not_great'),
('Gross', 'gross'),
))

def consumed_params(self):
return self.links.values()

def choices(self, cl):
selected = [v for v in self.links.values() if
self.params.has_key(v)]
for title, key in self.links.items():
yield {'selected': self.params.has_key(key),
'query_string': cl.get_query_string({key:1}, selected),
'display': title}

def get_query_set(self, cls, qs):
if self.params.has_key('so_intense'):
return qs.filter(name__icontains='bacon')
if self.params.has_key('good'):
return qs.filter(name__icontains='burger')
if self.params.has_key('not_great'):
return qs.filter(name__icontains='haggas')
if self.params.has_key('gross'):
return qs.filter(name__icontains='guano')

return qs

def title(self):
return u'How yummy?'

class FoodAdmin(admin.ModelAdmin):
list_filter = [HowYummyFilterSpec]

admin.site.register(models.Food, FoodAdmin)
}}}

--
Ticket URL: <http://code.djangoproject.com/ticket/5833#comment:68>

Django

unread,
Aug 1, 2010, 3:47:40 PM8/1/10
to djang...@holovaty.com, django-...@googlegroups.com
#5833: Custom FilterSpecs
-------------------------------------------+--------------------------------
Reporter: Honza_Kral | Owner: jkocherhans
Status: assigned | Milestone:
Component: django.contrib.admin | Version: SVN
Resolution: | Keywords: nfa-someday list_filter filterspec nfa-changelist ep2008
Stage: Accepted | Has_patch: 1
Needs_docs: 1 | Needs_tests: 1
Needs_better_patch: 0 |
-------------------------------------------+--------------------------------
Comment (by bendavis78):

There was an issue when get_query_set returned an empty queryset, fixed in
latest patch.

--
Ticket URL: <http://code.djangoproject.com/ticket/5833#comment:69>

Django

unread,
Aug 8, 2010, 2:04:53 AM8/8/10
to djang...@holovaty.com, django-...@googlegroups.com
#5833: Custom FilterSpecs
-------------------------------------------+--------------------------------
Reporter: Honza_Kral | Owner: jkocherhans
Status: assigned | Milestone:
Component: django.contrib.admin | Version: SVN
Resolution: | Keywords: nfa-someday list_filter filterspec nfa-changelist ep2008
Stage: Accepted | Has_patch: 1
Needs_docs: 1 | Needs_tests: 1
Needs_better_patch: 0 |
-------------------------------------------+--------------------------------
Changes (by 3point2):

* cc: 3point2 (added)

--
Ticket URL: <http://code.djangoproject.com/ticket/5833#comment:70>

Django

unread,
Aug 8, 2010, 2:05:33 AM8/8/10
to djang...@holovaty.com, django-...@googlegroups.com
#5833: Custom FilterSpecs
-------------------------------------------+--------------------------------
Reporter: Honza_Kral | Owner: jkocherhans
Status: assigned | Milestone:
Component: django.contrib.admin | Version: SVN
Resolution: | Keywords: nfa-someday list_filter filterspec nfa-changelist ep2008
Stage: Accepted | Has_patch: 1
Needs_docs: 1 | Needs_tests: 1
Needs_better_patch: 0 |
-------------------------------------------+--------------------------------
Comment (by 3point2):

just wanted to +1 this, I think it would be a powerful feature (and I have
a current need for it)

--
Ticket URL: <http://code.djangoproject.com/ticket/5833#comment:71>

Django

unread,
Aug 17, 2010, 11:46:38 AM8/17/10
to djang...@holovaty.com, django-...@googlegroups.com
#5833: Custom FilterSpecs
-------------------------------------------+--------------------------------
Reporter: Honza_Kral | Owner: jkocherhans
Status: assigned | Milestone:
Component: django.contrib.admin | Version: SVN
Resolution: | Keywords: nfa-someday list_filter filterspec nfa-changelist ep2008
Stage: Accepted | Has_patch: 1
Needs_docs: 1 | Needs_tests: 1
Needs_better_patch: 0 |
-------------------------------------------+--------------------------------
Changes (by anonymous):

* cc: SafPlusPlus (added)

--
Ticket URL: <http://code.djangoproject.com/ticket/5833#comment:72>

Django

unread,
Aug 23, 2010, 8:25:55 PM8/23/10
to djang...@holovaty.com, django-...@googlegroups.com
#5833: Custom FilterSpecs
-------------------------------------------+--------------------------------
Reporter: Honza_Kral | Owner: jkocherhans
Status: assigned | Milestone:
Component: django.contrib.admin | Version: SVN
Resolution: | Keywords: nfa-someday list_filter filterspec nfa-changelist ep2008
Stage: Accepted | Has_patch: 1
Needs_docs: 1 | Needs_tests: 1
Needs_better_patch: 0 |
-------------------------------------------+--------------------------------
Changes (by anonymous):

* cc: krasn...@gmail.com (added)

Comment:

Replying to [ticket:5833 Honza_Kral]:
> One should be able to create custom `FilterSpecs` for the admin's
`list_filter` interface.
>
> Honza_Kral: I modified the filterspec definition to allow for users to
register their own filters in admin. The mechanism is simple - I just
reverted the order of the registry so that newly registered specs will
come first. That way if you register your own filter via
{{{FilterSpec.register}}}, it will be used before the default one.
>
> Another approach by korpios is described in the comments.

--
Ticket URL: <http://code.djangoproject.com/ticket/5833#comment:73>

Django

unread,
Sep 2, 2010, 3:45:55 PM9/2/10
to djang...@holovaty.com, django-...@googlegroups.com
#5833: Custom FilterSpecs
-------------------------------------------+--------------------------------
Reporter: Honza_Kral | Owner: jkocherhans
Status: assigned | Milestone:
Component: django.contrib.admin | Version: SVN
Resolution: | Keywords: nfa-someday list_filter filterspec nfa-changelist ep2008
Stage: Accepted | Has_patch: 1
Needs_docs: 1 | Needs_tests: 1
Needs_better_patch: 0 |
-------------------------------------------+--------------------------------
Changes (by subsume):

* cc: sub...@gmail.com (added)

Comment:

One problem I have with this--and this may be completely irrelevant, is
the get_query_set method.

The problem I see is that it accepts and returns a filtered queryset and
these FilterSpecs chain like so:

Model.objects.filter(x=y).filter(z=y).filter(a=y)

When it comes to related objects, this is a problem because:

Model.objects.filter(x__z=y).filter(x__y=z).filter(y__x=a)

...is not the same as:

Model.objects.filter(Q(x__z=y)&Q(x__y=z)&Q(y__x=a))

One solution may be to allow get_query_set to return a Q() object and then
string them together as above. Sure, you're still locked into a chain of
&-joined Q objects but you already are and it could be the stuff of future
tickets.

If there's a better place to have this discussion please forward me along.
=). Thanks.

--
Ticket URL: <http://code.djangoproject.com/ticket/5833#comment:74>

Django

unread,
Sep 2, 2010, 3:59:22 PM9/2/10
to djang...@holovaty.com, django-...@googlegroups.com
#5833: Custom FilterSpecs
-------------------------------------------+--------------------------------
Reporter: Honza_Kral | Owner: jkocherhans
Status: assigned | Milestone:
Component: django.contrib.admin | Version: SVN
Resolution: | Keywords: nfa-someday list_filter filterspec nfa-changelist ep2008
Stage: Accepted | Has_patch: 1
Needs_docs: 1 | Needs_tests: 1
Needs_better_patch: 0 |
-------------------------------------------+--------------------------------
Comment (by fas):

Can you please give a concrete example where multiple filter spec are used
in such a way that it causes a problem?

--
Ticket URL: <http://code.djangoproject.com/ticket/5833#comment:75>

Django

unread,
Sep 3, 2010, 1:29:42 PM9/3/10
to djang...@holovaty.com, django-...@googlegroups.com
#5833: Custom FilterSpecs
-------------------------------------------+--------------------------------
Reporter: Honza_Kral | Owner: jkocherhans
Status: assigned | Milestone:
Component: django.contrib.admin | Version: SVN
Resolution: | Keywords: nfa-someday list_filter filterspec nfa-changelist ep2008
Stage: Accepted | Has_patch: 1
Needs_docs: 1 | Needs_tests: 1
Needs_better_patch: 0 |
-------------------------------------------+--------------------------------
Comment (by subsume):

Multiple filter specs won't become a problem until this feature is
implemented. Right now, list_filter only accepts fields on the model in
question. With this proposal FilterSpecs will now be opened up to conduct
querying on related fields.

Concrete example: Take a situation where you have Person and related to it
is a StaffContact. You have Person registered in Admin and you create two
FilterSpecs, one called 'Contacted by' (which looks at the user field of
StaffContact) and another called 'Contact range' (which looks at the field
of StaffContact). Using these two fields together based on this
implementation, chained fields can't give you all Person objects who were
contacted by BOTH a particular staff person AND a particular date range,
which might very well be preferable. Two JOINs will be created by this
proposal, whereas you may have wanted one.

--
Ticket URL: <http://code.djangoproject.com/ticket/5833#comment:76>

Django

unread,
Sep 30, 2010, 12:03:19 AM9/30/10
to djang...@holovaty.com, django-...@googlegroups.com
#5833: Custom FilterSpecs
---------------------------------------------+------------------------------
Reporter: Honza_Kral | Owner: jkocherhans
Status: assigned | Milestone:
Component: django.contrib.admin | Version: SVN
Resolution: | Keywords: nfa-someday list_filter filterspec nfa-changelist ep2008
Stage: Design decision needed | Has_patch: 1
Needs_docs: 1 | Needs_tests: 1
Needs_better_patch: 0 |
---------------------------------------------+------------------------------
Changes (by subsume):

* stage: Accepted => Design decision needed

Comment:

switched back to design decision needed.

--
Ticket URL: <http://code.djangoproject.com/ticket/5833#comment:77>

Django

unread,
Oct 1, 2010, 12:04:10 PM10/1/10
to djang...@holovaty.com, django-...@googlegroups.com
#5833: Custom FilterSpecs
-------------------------------------------+--------------------------------
Reporter: Honza_Kral | Owner: jkocherhans
Status: assigned | Milestone:
Component: django.contrib.admin | Version: SVN
Resolution: | Keywords: nfa-someday list_filter filterspec nfa-changelist ep2008
Stage: Accepted | Has_patch: 1
Needs_docs: 1 | Needs_tests: 1
Needs_better_patch: 0 |
-------------------------------------------+--------------------------------
Changes (by subsume):

* stage: Design decision needed => Accepted

Comment:

switched back to accepted.

--
Ticket URL: <http://code.djangoproject.com/ticket/5833#comment:78>

Django

unread,
Nov 9, 2010, 10:01:01 PM11/9/10
to djang...@holovaty.com, django-...@googlegroups.com
#5833: Custom FilterSpecs
-------------------------------------------+--------------------------------
Reporter: Honza_Kral | Owner: jkocherhans
Status: assigned | Milestone:
Component: django.contrib.admin | Version: SVN
Resolution: | Keywords: nfa-someday list_filter filterspec nfa-changelist ep2008
Stage: Accepted | Has_patch: 1
Needs_docs: 1 | Needs_tests: 1
Needs_better_patch: 0 |
-------------------------------------------+--------------------------------
Changes (by simon29):

* cc: simon29 (added)

--
Ticket URL: <http://code.djangoproject.com/ticket/5833#comment:79>

Django

unread,
Nov 11, 2010, 6:54:17 AM11/11/10
to djang...@holovaty.com, django-...@googlegroups.com
#5833: Custom FilterSpecs
-------------------------------------------+--------------------------------
Reporter: Honza_Kral | Owner: jkocherhans
Status: assigned | Milestone:
Component: django.contrib.admin | Version: SVN
Resolution: | Keywords: nfa-someday list_filter filterspec nfa-changelist ep2008
Stage: Accepted | Has_patch: 1
Needs_docs: 1 | Needs_tests: 1
Needs_better_patch: 0 |
-------------------------------------------+--------------------------------
Changes (by dirleyrls):

* cc: dirl...@gmail.com (added)

--
Ticket URL: <http://code.djangoproject.com/ticket/5833#comment:80>

Django

unread,
Nov 15, 2010, 8:51:20 PM11/15/10
to djang...@holovaty.com, django-...@googlegroups.com
#5833: Custom FilterSpecs
-------------------------------------------+--------------------------------
Reporter: Honza_Kral | Owner: jkocherhans
Status: assigned | Milestone:
Component: django.contrib.admin | Version: SVN
Resolution: | Keywords: nfa-someday list_filter filterspec nfa-changelist ep2008
Stage: Accepted | Has_patch: 1
Needs_docs: 1 | Needs_tests: 1
Needs_better_patch: 0 |
-------------------------------------------+--------------------------------
Comment (by simon29):

See also #8528, which still makes sense even if this patch goes in. It
provides a sensible default for null=True/blank=True fields, by giving the
None option; where this ticket gives full control.

--
Ticket URL: <http://code.djangoproject.com/ticket/5833#comment:81>

Django

unread,
Nov 21, 2010, 2:24:06 PM11/21/10
to djang...@holovaty.com, django-...@googlegroups.com
#5833: Custom FilterSpecs
-------------------------------------------+--------------------------------
Reporter: Honza_Kral | Owner: jkocherhans
Status: assigned | Milestone:
Component: django.contrib.admin | Version: SVN
Resolution: | Keywords: nfa-someday list_filter filterspec nfa-changelist ep2008
Stage: Accepted | Has_patch: 1
Needs_docs: 1 | Needs_tests: 1
Needs_better_patch: 0 |
-------------------------------------------+--------------------------------
Changes (by vitek_pliska):

* cc: vitek_pliska (added)

--
Ticket URL: <http://code.djangoproject.com/ticket/5833#comment:82>

Django

unread,
Nov 21, 2010, 3:20:45 PM11/21/10
to djang...@holovaty.com, django-...@googlegroups.com
#5833: Custom FilterSpecs
-------------------------------------------+--------------------------------
Reporter: Honza_Kral | Owner: jkocherhans
Status: assigned | Milestone:
Component: django.contrib.admin | Version: SVN
Resolution: | Keywords: nfa-someday list_filter filterspec nfa-changelist ep2008
Stage: Accepted | Has_patch: 1
Needs_docs: 1 | Needs_tests: 1
Needs_better_patch: 0 |
-------------------------------------------+--------------------------------
Changes (by brentp):

* cc: bped...@gmail.com (removed)

--
Ticket URL: <http://code.djangoproject.com/ticket/5833#comment:83>

Django

unread,
Nov 22, 2010, 5:03:39 AM11/22/10
to djang...@holovaty.com, django-...@googlegroups.com
#5833: Custom FilterSpecs
-------------------------------------------+--------------------------------
Reporter: Honza_Kral | Owner: jkocherhans
Status: assigned | Milestone:
Component: django.contrib.admin | Version: SVN
Resolution: | Keywords: nfa-someday list_filter filterspec nfa-changelist ep2008
Stage: Accepted | Has_patch: 1
Needs_docs: 1 | Needs_tests: 1
Needs_better_patch: 0 |
-------------------------------------------+--------------------------------
Comment (by jovanb):

Replying to [comment:69 bendavis78]:

Custom FilterSpec on a Model level instead of field level is frequently
needed feature (ast least in my case), so thumbs-up for this patch.

--
Ticket URL: <http://code.djangoproject.com/ticket/5833#comment:84>

Django

unread,
Dec 9, 2010, 3:09:47 PM12/9/10
to djang...@holovaty.com, django-...@googlegroups.com
#5833: Custom FilterSpecs
-------------------------------------------+--------------------------------
Reporter: Honza_Kral | Owner: jkocherhans
Status: assigned | Milestone:
Component: django.contrib.admin | Version: SVN
Resolution: | Keywords: nfa-someday list_filter filterspec nfa-changelist ep2008
Stage: Accepted | Has_patch: 1
Needs_docs: 1 | Needs_tests: 1
Needs_better_patch: 0 |
-------------------------------------------+--------------------------------
Comment (by bendavis78):

This patch needs a major overhaul for 1.3. A lot of changes happened with
the fix for #3400, see changeset r14674 for more info.

--
Ticket URL: <http://code.djangoproject.com/ticket/5833#comment:85>

Django

unread,
Dec 9, 2010, 7:39:38 PM12/9/10
to djang...@holovaty.com, django-...@googlegroups.com
#5833: Custom FilterSpecs
-------------------------------------------+--------------------------------
Reporter: Honza_Kral | Owner: jkocherhans
Status: assigned | Milestone:
Component: django.contrib.admin | Version: SVN
Resolution: | Keywords: nfa-someday list_filter filterspec nfa-changelist ep2008
Stage: Accepted | Has_patch: 1
Needs_docs: 1 | Needs_tests: 1
Needs_better_patch: 0 |
-------------------------------------------+--------------------------------
Comment (by bendavis78):

I took a stab at a patch for 1.3 -- approch w/ caution, YMMV, etc.. The
validation logic seemed somewhat flawed, so I cleaned that up a bit. I
wasn't too sure about whether or not to include subsume's changes. I
think that still needs a little more discussion.

We still need TESTS and DOCUMENTATION on this.

--
Ticket URL: <http://code.djangoproject.com/ticket/5833#comment:86>

Django

unread,
Dec 9, 2010, 7:52:22 PM12/9/10
to djang...@holovaty.com, django-...@googlegroups.com
#5833: Custom FilterSpecs
-------------------------------------------+--------------------------------
Reporter: Honza_Kral | Owner: jkocherhans
Status: assigned | Milestone:
Component: django.contrib.admin | Version: SVN
Resolution: | Keywords: nfa-someday list_filter filterspec nfa-changelist ep2008
Stage: Accepted | Has_patch: 1
Needs_docs: 1 | Needs_tests: 1
Needs_better_patch: 0 |
-------------------------------------------+--------------------------------
Comment (by subsume):

I can only have so much discussion with myself. You either agree I have
raised a valid limitation or you don't. You agree that my solution is a
comprimising approach to open up more functionality, or you don't. There's
a buzzword for this patch.... stopgap. Nobody has run into this problem
filtering relations? Really? I was asked for examples and I gave them,
then I wrote a patch. I think my changes deserve ample consideration.

--
Ticket URL: <http://code.djangoproject.com/ticket/5833#comment:87>

Django

unread,
Dec 10, 2010, 9:03:01 AM12/10/10
to djang...@holovaty.com, django-...@googlegroups.com
#5833: Custom FilterSpecs
-------------------------------------------+--------------------------------
Reporter: Honza_Kral | Owner: jkocherhans
Status: assigned | Milestone:
Component: django.contrib.admin | Version: SVN
Resolution: | Keywords: nfa-someday list_filter filterspec nfa-changelist ep2008
Stage: Accepted | Has_patch: 1
Needs_docs: 1 | Needs_tests: 1
Needs_better_patch: 0 |
-------------------------------------------+--------------------------------
Comment (by bendavis78):

I never said they didn't deserve consideration. I guess i'm still not
sure I understand the problem your patch addresses (your example wasn't
very clear to me). It seems to me that returning a queryset is the
cleanest way. I may be wrong, I'm just not convinced otherwise. I'll
look over it some more today.

--
Ticket URL: <http://code.djangoproject.com/ticket/5833#comment:88>

Django

unread,
Dec 10, 2010, 11:25:02 AM12/10/10
to djang...@holovaty.com, django-...@googlegroups.com
#5833: Custom FilterSpecs
-------------------------------------------+--------------------------------
Reporter: Honza_Kral | Owner: jkocherhans
Status: assigned | Milestone:
Component: django.contrib.admin | Version: SVN
Resolution: | Keywords: nfa-someday list_filter filterspec nfa-changelist ep2008
Stage: Accepted | Has_patch: 1
Needs_docs: 1 | Needs_tests: 1
Needs_better_patch: 0 |
-------------------------------------------+--------------------------------
Comment (by bendavis78):

@subsume, would you be able to provide a more concrete example than the
one you gave earlier (e.g., models and example filterspecs)? It seems to
me that most people would expect multiple filter specs to act like
multiple .filter() calls. Each chain in the queryset further refines the
previous one. Plus, if you take away the ability to modify the queryset,
you're taking away a lot of flexibility (eg, the use of .exclude(),
.extra(), etc...).

--
Ticket URL: <http://code.djangoproject.com/ticket/5833#comment:89>

Django

unread,
Dec 10, 2010, 1:11:10 PM12/10/10
to djang...@holovaty.com, django-...@googlegroups.com
#5833: Custom FilterSpecs
-------------------------------------------+--------------------------------
Reporter: Honza_Kral | Owner: jkocherhans
Status: assigned | Milestone:
Component: django.contrib.admin | Version: SVN
Resolution: | Keywords: nfa-someday list_filter filterspec nfa-changelist ep2008
Stage: Accepted | Has_patch: 1
Needs_docs: 1 | Needs_tests: 1
Needs_better_patch: 0 |
-------------------------------------------+--------------------------------
Comment (by subsume):

I can try and say it again plainly: filtering on fields of a related table
will be done in separate JOINs using this method, whereas you may (and
probably did...) only want one. If you try and filter for Companys that
have a Location that is 1) open_saturday=True and 2) zip_code = 90210, the
current approach leaves you in the cold because of how chained filtering
works.

The current syntax is very seductive because of its simplicity but what is
the point of a beautiful API that doesn't give you what you want?

You are not losing any flexibility--its wrong to say you can't use
exclude(), extra(), etc--you most certainly can, its just a matter of
knowing how Q and Q-like objects work (For example: "exclude" is simply
~Q(somefilter=True). Not difficult at all). From the perspective of
filtering records, Q objects and their like are a more mature way to go
about it because of their great mutability.

--
Ticket URL: <http://code.djangoproject.com/ticket/5833#comment:90>

Django

unread,
Dec 10, 2010, 6:20:19 PM12/10/10
to djang...@holovaty.com, django-...@googlegroups.com
#5833: Custom FilterSpecs
-------------------------------------------+--------------------------------
Reporter: Honza_Kral | Owner: jkocherhans
Status: assigned | Milestone:
Component: django.contrib.admin | Version: SVN
Resolution: | Keywords: nfa-someday list_filter filterspec nfa-changelist ep2008
Stage: Accepted | Has_patch: 1
Needs_docs: 1 | Needs_tests: 1
Needs_better_patch: 0 |
-------------------------------------------+--------------------------------
Comment (by bendavis78):

again, it would really help if you could give a test case (models.py and
admin.py) so we can get a good idea of the problem you're encountering.
For me, chaining the filters together produces the same effect as a &'d Q
objects. I'm still not sure I understand what the actual undesired
outcome is, which is why some concrete examples would help. Sorry, not
trying to be a pain -- just having trouble grasping the issue you're
raising.

--
Ticket URL: <http://code.djangoproject.com/ticket/5833#comment:91>

Django

unread,
Dec 10, 2010, 6:55:57 PM12/10/10
to djang...@holovaty.com, django-...@googlegroups.com
#5833: Custom FilterSpecs
-------------------------------------------+--------------------------------
Reporter: Honza_Kral | Owner: jkocherhans
Status: assigned | Milestone:
Component: django.contrib.admin | Version: SVN
Resolution: | Keywords: nfa-someday list_filter filterspec nfa-changelist ep2008
Stage: Accepted | Has_patch: 1
Needs_docs: 1 | Needs_tests: 1
Needs_better_patch: 0 |
-------------------------------------------+--------------------------------
Comment (by bendavis78):

subsume, I went ahead and created a test case for what I _think_ you're
claiming is a problem, and I can't find the problem. You can get the
code here: https://github.com/bendavis78/filter-test . Each of the
filterspecs seems to behave as one would expect. Let me know what I'm
missing.

--
Ticket URL: <http://code.djangoproject.com/ticket/5833#comment:92>

Django

unread,
Dec 10, 2010, 8:47:40 PM12/10/10
to djang...@holovaty.com, django-...@googlegroups.com
#5833: Custom FilterSpecs
-------------------------------------------+--------------------------------
Reporter: Honza_Kral | Owner: jkocherhans
Status: assigned | Milestone:
Component: django.contrib.admin | Version: SVN
Resolution: | Keywords: nfa-someday list_filter filterspec nfa-changelist ep2008
Stage: Accepted | Has_patch: 1
Needs_docs: 1 | Needs_tests: 1
Needs_better_patch: 0 |
-------------------------------------------+--------------------------------
Comment (by subsume):

Excellent work. I added a test to that github and sent you a pull request
to review.

--
Ticket URL: <http://code.djangoproject.com/ticket/5833#comment:93>

Django

unread,
Dec 13, 2010, 2:54:34 PM12/13/10
to djang...@holovaty.com, django-...@googlegroups.com
#5833: Custom FilterSpecs
-------------------------------------------+--------------------------------
Reporter: Honza_Kral | Owner: jkocherhans
Status: assigned | Milestone:
Component: django.contrib.admin | Version: SVN
Resolution: | Keywords: nfa-someday list_filter filterspec nfa-changelist ep2008
Stage: Accepted | Has_patch: 1
Needs_docs: 1 | Needs_tests: 1
Needs_better_patch: 0 |
-------------------------------------------+--------------------------------
Comment (by bendavis78):

@subsume, I see what you're getting at. I still, however, think that
yours is a rare use-case. In the case of the Comapnies/Locations example,
I think it would make more sense to just have a !LocationAdmin to filter
on locations. While I still think most developers would want the default
behavior to work like a normal queryset chain, I can see the benefit of
having the option open, so as a compromise I propose we move the querset
processing code out into a different function so that the default behavior
can be overidden:

(from django/contrib/admin/views/main.py, near line 178)
{{{
#!python

def apply_filter_specs(self, qs, lookup_params):
# Let every filter spec modify the qs and params to its liking
for filter_spec in self.filter_specs:
new_qs = filter_spec.get_query_set(self, qs)
if new_qs is not None and new_qs is not False:
qs = new_qs
# Only consume params if we got a new queryset
for param in filter_spec.consumed_params():
try:
del lookup_params[param]
except KeyError:
pass
return qs

def get_query_set(self):
qs = self.root_query_set
lookup_params = self.params.copy() # a dictionary of the query
string
for i in (ALL_VAR, ORDER_VAR, ORDER_TYPE_VAR, SEARCH_VAR,
IS_POPUP_VAR):
if i in lookup_params:
del lookup_params[i]
key = ''
for key, value in lookup_params.items():
if not isinstance(key, str):
# 'key' will be used as a keyword argument later, so
Python
# requires it to be a string.
del lookup_params[key]
lookup_params[smart_str(key)] = value

# if key ends with __in, split parameter into separate values
if key.endswith('__in'):
lookup_params[key] = value.split(',')

# if key ends with __isnull, special case '' and false
if key.endswith('__isnull'):
if value.lower() in ('', 'false'):
lookup_params[key] = False
else:
lookup_params[key] = True

qs = self.apply_filter_specs(qs, lookup_params)

# Apply lookup parameters from the query string.
}}}

In your case, you would be able to override apply_filter_specs in to
change that behavior. By no means am i the authority on this ticket, so
if anyone else can chime with their opinion please do.

--
Ticket URL: <http://code.djangoproject.com/ticket/5833#comment:94>

Django

unread,
Dec 13, 2010, 3:11:25 PM12/13/10
to djang...@holovaty.com, django-...@googlegroups.com
#5833: Custom FilterSpecs
-------------------------------------------+--------------------------------
Reporter: Honza_Kral | Owner: jkocherhans
Status: assigned | Milestone:
Component: django.contrib.admin | Version: SVN
Resolution: | Keywords: nfa-someday list_filter filterspec nfa-changelist ep2008
Stage: Accepted | Has_patch: 1
Needs_docs: 1 | Needs_tests: 1
Needs_better_patch: 0 |
-------------------------------------------+--------------------------------
Comment (by subsume):

Definitely happy with this. Thanks.

--
Ticket URL: <http://code.djangoproject.com/ticket/5833#comment:95>

Django

unread,
Dec 15, 2010, 5:06:00 AM12/15/10
to djang...@holovaty.com, django-...@googlegroups.com
#5833: Custom FilterSpecs
-------------------------------------------+--------------------------------
Reporter: Honza_Kral | Owner: jkocherhans
Status: assigned | Milestone:
Component: django.contrib.admin | Version: SVN
Resolution: | Keywords: nfa-someday list_filter filterspec nfa-changelist ep2008
Stage: Accepted | Has_patch: 1
Needs_docs: 1 | Needs_tests: 1
Needs_better_patch: 0 |
-------------------------------------------+--------------------------------
Changes (by spinyol):

* cc: spinyol (added)

--
Ticket URL: <http://code.djangoproject.com/ticket/5833#comment:96>

Django

unread,
Jan 5, 2011, 12:32:45 AM1/5/11
to djang...@holovaty.com, django-...@googlegroups.com
#5833: Custom FilterSpecs
-------------------------------------------+--------------------------------
Reporter: Honza_Kral | Owner: jkocherhans
Status: assigned | Milestone:
Component: django.contrib.admin | Version: SVN
Resolution: | Keywords: nfa-someday list_filter filterspec nfa-changelist ep2008
Stage: Accepted | Has_patch: 1
Needs_docs: 1 | Needs_tests: 1
Needs_better_patch: 0 |
-------------------------------------------+--------------------------------
Changes (by charettes):

* cc: charettes (added)

--
Ticket URL: <http://code.djangoproject.com/ticket/5833#comment:97>

Django

unread,
Jan 14, 2011, 6:14:28 AM1/14/11
to djang...@holovaty.com, django-...@googlegroups.com
#5833: Custom FilterSpecs
-------------------------------------------+--------------------------------
Reporter: Honza_Kral | Owner: jkocherhans
Status: assigned | Milestone:
Component: django.contrib.admin | Version: SVN
Resolution: | Keywords: nfa-someday list_filter filterspec nfa-changelist ep2008
Stage: Accepted | Has_patch: 1
Needs_docs: 1 | Needs_tests: 1
Needs_better_patch: 0 |
-------------------------------------------+--------------------------------
Changes (by shanx):

* cc: re...@maykinmedia.nl (added)

--
Ticket URL: <http://code.djangoproject.com/ticket/5833#comment:98>

Django

unread,
Jan 18, 2011, 1:12:08 AM1/18/11
to djang...@holovaty.com, django-...@googlegroups.com
#5833: Custom FilterSpecs
-------------------------------------------+--------------------------------
Reporter: Honza_Kral | Owner: jkocherhans
Status: assigned | Milestone:
Component: django.contrib.admin | Version: SVN
Resolution: | Keywords: nfa-someday list_filter filterspec nfa-changelist ep2008
Stage: Accepted | Has_patch: 1
Needs_docs: 1 | Needs_tests: 1
Needs_better_patch: 0 |
-------------------------------------------+--------------------------------
Comment (by charettes):

Is this ticket only missing docs and tests?

--
Ticket URL: <http://code.djangoproject.com/ticket/5833#comment:99>

Django

unread,
Jan 20, 2011, 5:36:06 AM1/20/11
to djang...@holovaty.com, django-...@googlegroups.com
#5833: Custom FilterSpecs
-------------------------------------------+--------------------------------
Reporter: Honza_Kral | Owner: jkocherhans
Status: assigned | Milestone:
Component: django.contrib.admin | Version: SVN
Resolution: | Keywords: nfa-someday list_filter filterspec nfa-changelist ep2008
Stage: Accepted | Has_patch: 1
Needs_docs: 1 | Needs_tests: 1
Needs_better_patch: 0 |
-------------------------------------------+--------------------------------
Changes (by anonymous):

* cc: rohit.a...@gmail.com (added)

--
Ticket URL: <http://code.djangoproject.com/ticket/5833#comment:100>

Django

unread,
Feb 3, 2011, 7:26:08 AM2/3/11
to djang...@holovaty.com, django-...@googlegroups.com
#5833: Custom FilterSpecs
------------------------------------------------+---------------------------
Reporter: Honza_Kral | Owner: jkocherhans
Status: assigned | Milestone: 1.3
Component: django.contrib.admin | Version: SVN
Resolution: | Keywords: nfa-someday list_filter filterspec nfa-changelist ep2008
Triage Stage: Accepted | Has patch: 1
Needs documentation: 1 | Needs tests: 1
Patch needs improvement: 0 |
------------------------------------------------+---------------------------
Changes (by anonymous):

* milestone: => 1.3


--
Ticket URL: <http://code.djangoproject.com/ticket/5833#comment:101>

Django

unread,
Feb 3, 2011, 7:29:12 AM2/3/11
to djang...@holovaty.com, django-...@googlegroups.com
#5833: Custom FilterSpecs
------------------------------------------------+---------------------------
Reporter: Honza_Kral | Owner: jkocherhans
Status: assigned | Milestone:
Component: django.contrib.admin | Version: SVN
Resolution: | Keywords: nfa-someday list_filter filterspec nfa-changelist ep2008
Triage Stage: Accepted | Has patch: 1
Needs documentation: 1 | Needs tests: 1
Patch needs improvement: 0 |
------------------------------------------------+---------------------------
Changes (by russellm):

* milestone: 1.3 =>


Comment:

1.3 feature deadline has passed.

--
Ticket URL: <http://code.djangoproject.com/ticket/5833#comment:102>

Django

unread,
Mar 9, 2011, 6:24:26 PM3/9/11
to djang...@holovaty.com, django-...@googlegroups.com
#5833: Custom FilterSpecs
-------------------------------------+-------------------------------------
Reporter: | Owner: jkocherhans
Honza_Kral | Milestone:
Status: assigned | Version: SVN
Component: | Keywords: nfa-someday
django.contrib.admin | list_filter filterspec nfa-
Resolution: | changelist ep2008
Triage Stage: Accepted | Has patch: 1
Needs documentation: 1 | Needs tests: 1
Patch needs improvement: 0 |
-------------------------------------+-------------------------------------
Changes (by jgelens):

* cc: jeffrey@… (added)


--
Ticket URL: <http://code.djangoproject.com/ticket/5833#comment:103>

Django

unread,
Mar 14, 2011, 6:25:43 PM3/14/11
to djang...@holovaty.com, django-...@googlegroups.com
#5833: Custom FilterSpecs
-------------------------------------+-------------------------------------
Reporter: | Owner: jkocherhans
Honza_Kral | Milestone:
Status: assigned | Version: SVN
Component: | Keywords: nfa-someday
django.contrib.admin | list_filter filterspec nfa-
Resolution: | changelist ep2008
Triage Stage: Accepted | Has patch: 1
Needs documentation: 1 | Needs tests: 1
Patch needs improvement: 0 |
-------------------------------------+-------------------------------------

Comment (by bendavis78):

Patch won't apply to 1.3-rc1. Working on a new patch.

--
Ticket URL: <http://code.djangoproject.com/ticket/5833#comment:104>

Django

unread,
Mar 15, 2011, 11:35:45 AM3/15/11
to djang...@holovaty.com, django-...@googlegroups.com
#5833: Custom FilterSpecs
-------------------------------------+-------------------------------------
Reporter: | Owner: jkocherhans
Honza_Kral | Milestone:
Status: assigned | Version: SVN
Component: | Keywords: nfa-someday
django.contrib.admin | list_filter filterspec nfa-
Resolution: | changelist ep2008
Triage Stage: Accepted | Has patch: 1
Needs documentation: 1 | Needs tests: 1
Patch needs improvement: 0 |
-------------------------------------+-------------------------------------

Comment (by ramiro):

#15615 (closed as duplicate) asks for the same feature.

--
Ticket URL: <http://code.djangoproject.com/ticket/5833#comment:105>

It is loading more messages.
0 new messages