in django we can chain multiple filter methods like:
MyModel.objects.filter(field1__exact=value1).filter(field2__exact=value2)
but I'd like to be able to chain custom filter methods defined by
extending the models.Manager class.
For example:
MyModel.objects.filter(field1__exact=value1).my_filter(field2)
In other words I'd like to be able to apply the filter directly to a
queryset and not only to MyModel.objects.
Do you have any suggestion on how to accomplish that?
Thanks a lot
Francesco
Sub-class the QuerySet class and have your model's manager return your
subclass as the result of get_query_set() rather than the current
QuerySet instance that is returned.
Look in django/db/models/manager.py for the default manager behaviour
and write something similar for get_query_set().
Regards,
Malcolm
--
Tolkien is hobbit-forming.
http://www.pointy-stick.com/blog/