#5833: Custom FilterSpecs
-------------------------------------+-------------------------------------
Reporter: | Owner: jkocherhans
Honza_Kral | Status: assigned
Type: New | Component: contrib.admin
feature | Severity: Normal
Milestone: | Keywords: nfa-someday
Version: SVN | list_filter filterspec nfa-
Resolution: | changelist ep2008
Triage Stage: Accepted | Has patch: 1
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
-------------------------------------+-------------------------------------
Changes (by julien):
* needs_better_patch: 1 => 0
Comment:
The latest patch addresses some of fas's concerns, i.e.:
* `get_query_set` is always executed. If it returns nothing (or explicitly
returns None) then the filter is ignored.
* The request is not passed as a parameter to the filter's methods any
more. Instead it is accessible via `self.request` as a convenience.
* `_choices()` was renamed `get_output_choices()`.
I think these points also address Karen's initial concerns and simplifies
the API too.
I have also renamed `ListFilter` from the previous patch (which also used
to be called `SimpleListFilter` in a patch before that) to
`SingleQueryParameterListFilter`. This is a bit of a mouthful but at least
it is explicit. Now, clearly, this is a specialized class rather than
something claiming to address all use cases. The goal here is to provide a
dead-simple API to cover a very common use case where there is only query
parameter to deal with. I see this having a similar use as the
`simple_tag` helper function which allows the creation of simple tags
without having to deal with too much boilerplatey code. This approach also
leaves the door open to adding more specialized filter classes in the
future. By the way, fas, if you wish to have multiple parameters and a
more complex logic, then you can continue doing the same as you always
have.
The patch includes a pretty comprehensive test suite and doc to reflect
how it all works. At this stage I think I have addressed all pending
questions while allowing for an easy way of creating simple custom
filters.
Any feedback would now be welcome to help move this forward. Thanks!
--
Ticket URL: <http://code.djangoproject.com/ticket/5833#comment:123>
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 [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en.