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, <j...@eyrie.in> wrote:

> I'm trying to do a case insensitive search for a substring within a field
> in my model.
>
> My model:
>
>
> class doctor(models.Model):
>         docid = models.AutoField(primary_key=True, unique=True) # Need
> autoincrement, unique and primary
>         name = models.CharField(max_length=35)
>         username = models.CharField(max_length=15)
>         regid = models.CharField(max_length=15, default="", blank=True)
>         photo = models.CharField(
>             max_length=35, default="", blank=True)
>         email = models.EmailField(default="", blank=True)
>         phone = models.CharField(max_length=15)
>         qualifications = models.CharField(
>             max_length=50, default="", blank=True)
>         about = models.CharField(
>             max_length=35, default="", blank=True)
>         specialities = models.CharField(
>             max_length=50, default="", blank=True)
>         department = models.CharField(max_length=50, default="ENT", blank=
> True)
>         fees = models.FloatField(default=300.0)
>         displayfee = models.IntegerField(default=0, blank=True)
>         slotrange = models.CharField(max_length=50, blank=True)
>         slotdurn = models.IntegerField(default=10)
>         breakrange = models.CharField(
>             max_length=50, default="", blank=True)
>         slotsleft = models.CharField(
>             max_length=50, default="", blank=True)
>         def __str__(self):
>             return self.name
>         def Range(self):
>             return self.slotrange
>         def listslots(self):
>             SlotRange = self.slotrange
>             SlotDurn = self.slotdurn
>             startime = SlotRange.split('-')[0]
>             endtime = SlotRange.split('-')[1]
>             sthr, stmin = SplitTimeString(startime)
>             enhr, enmin = SplitTimeString(endtime)
>             print(stamptoday(sthr, stmin))
>             print(stamptoday(enhr, enmin))
>             startstamp = stamptoday(sthr, stmin)
>             endstamp = stamptoday(enhr, enmin)
>             secdurn = SlotDurn*60
>             slotlist = []
>             for sec in range(startstamp, endstamp, secdurn):
>                 enttime = sec + secdurn
>                 myrange = ("%s - %s" % (HumanTime(sec),
>                                         HumanTime(enttime)))
>                 slotlist.append(myrange)
>             return slotlist
>
>
> Under the field 'name' in my mysql database, are two rows with values for
> name as 'Joel' and 'Jaffy Joel'.
>
> When I do the search like this:
>
>
> from appointments.models import customer, doctor, appointment
>     doctor.objects.filter(name__icontains='joel')
>
>
> Output:
>
>
> <QuerySet []>
>
>
> But when I do:
>
>     doctor.objects.filter(name__icontains='Joel')
>
>
>
> Output:
>
>
>  <QuerySet [<doctor: Joel>, <doctor: Jaffy Joel>]>
>
>
> Why isnt the case insensitive search working for a lowercase search?
>
> I'm on django 2.0.7
>
> --
> 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 django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/46579c92-8a12-4977-814c-9c3fcaa14711%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/46579c92-8a12-4977-814c-9c3fcaa14711%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAO87g11GdDTaDAVNUXmn-09j7ZQ2c8Jr_kR6pc-6aq6L8JTjAg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to