Re: Unexpected behavior with icontains in query filter

2018-08-11 Thread Jason
Check out https://code.djangoproject.com/ticket/9682. Apparently this is a mysql specific thing. -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to

Re: Unexpected behavior with icontains in query filter

2018-08-11 Thread Joel Mathew
This workaround works. In [10]: from django.db.models.functions import Lower In [11]: from django.db.models import CharField In [12]: CharField.register_lookup(Lower, "lower") Out[12]: django.db.models.functions.base.Lower In [13]: doctor.objects.filter(name__lower__contains="joel") Out[13]: ,

Re: Unexpected behavior with icontains in query filter

2018-08-11 Thread Joel Mathew
This is what I got: In [8]: doct = doctor.objects.filter(name__icontains = 'joel') ...: print(doct.query) SELECT `appointments_doctor`.`docid`, `appointments_doctor`.`name`, `appointments_doctor`.`username`, `appointments_doctor`.`regid`, `appointments_doctor`.`photo`,

Re: Unexpected behavior with icontains in query filter

2018-08-11 Thread ireoluwa fakeye
The only reasonable explanation is Django sees only upper case inputs as being case sensitive .so inputting a lower case and specifying icontains wouldnt change anything .you could get your input from a form to confirm On Fri., 10 Aug. 2018, 18:06 Joel, wrote: > I'm trying to do a case

Re: Unexpected behavior with icontains in query filter

2018-08-11 Thread Jason
Are you using sqlite for your db? if so, there are some notes about case insensitive matching at https://docs.djangoproject.com/en/dev/ref/databases/#sqlite-string-matching otherwise, I'd be interested in seeing what your SQL is like in your django shell, do the following: doctors =

RE: Unexpected behavior with icontains in query filter

2018-08-10 Thread Matthew Pava
I’m fascinated by this problem. Try this workaround. https://docs.djangoproject.com/en/2.0/ref/models/database-functions/#lower Register the lookup Lower like so: CharField.register_lookup(Lower, "lower") Then use the contains lookup. doctor.objects.filter(name__lower__contains="joel") From: