#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 <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
-~----------~----~----~----~------~----~------~--~---