On Mon, Dec 10, 2012 at 05:34:57AM -0800, marl�ne gratigny wrote:
> Hello,
> First thank you very much for django-filters, it's a very useful tool.
> I trying to make a filter on a field with a keyword, not the complete
> information into a field. With django, i do that with __icontains. Can I do
> the same filter with django-filters?
> If yes, can you explain me how to do that?
> Thanks for your help
Suppose your field is named 'keywords', I guess you need something like:
class MyFilterset(django_filters.Filterset):
keyword = django_filters.CharField(lookup_type='icontais')
class Meta:
model = YourModel
fields = ['keywords']
Aleternatively you can add to MyFilterset:
def __init__(self, *args, **kwargs):
django_filters.FilterSet.__init__(self, *args, **kwargs)
self.filters['keywords'].lookup_type = 'icontains'
sandro
*:-)
--
Sandro Dentella *:-)
http://www.reteisi.org Soluzioni libere per le scuole
http://sqlkit.argolinux.org SQLkit home page - PyGTK/python/sqlalchemy