Django--Making query use part of the matching name

2018-04-25 Thread shawnmhy
Hello everyone! Currently I am working on Django. I defined a 'Search' function in views.py: def search(request): q = request.GET.get("q") if q: ReactResul = Reactionsmeta.objects.filter(id__contains=q) MetaResul = Metabolites.objects.filter(id__contains=q) GeneRe

Re: Django--Making query use part of the matching name

2018-04-25 Thread James Farris
I believe you want to use icontains rather than contains. It’s case insensitive. I’m not sure without using regex it’s possible to return the results based on any character in any order in the search string. > On Apr 25, 2018, at 5:13 PM, shawn...@gmail.com wrote: > > Hello everyone! > > Cu

Re: Django--Making query use part of the matching name

2018-04-26 Thread shawnmhy
Thank you for your help! And yes, I think I should use regex. But could you please show me how to use it in my example, since I am new to django.. 在 2018年4月26日星期四 UTC+1上午2:14:10,James Farris写道: > > I believe you want to use icontains rather than contains. It’s case > insensitive. > > I’m not su

Re: Django--Making query use part of the matching name

2018-04-26 Thread James Farris
Try using filter(id__regex=r'\w’) I’m not sure if this will give you the exact results your looking for, but worth a shot. Sent from my mobile device > On Apr 26, 2018, at 2:31 AM, shawn...@gmail.com wrote: > > Thank you for your help! And yes, I think I should use regex. But could you > pl

Re: Django--Making query use part of the matching name

2018-04-26 Thread shawnmhy
But how about my query string? I am using 'q' as the search term 在 2018年4月26日星期四 UTC下午3:19:15,James Farris写道: > > Try using filter(id__regex=r'\w’) > > I’m not sure if this will give you the exact results your looking for, but > worth a shot. > > > Sent from my mobile device > > On Apr 26, 2018,

Re: Django--Making query use part of the matching name

2018-04-28 Thread 'Anthony Flury' via Django users
What are the rules - you say that a query string of '10FTK' should match '10FTH86RSK', but also '10FTK', '10F6TK', '10FTK4' I think the problem is that the rules aren't 100% clear. * For '10FTK' to match '10FTH' you actually only care about the first 4 characters ? * For '10FTK' to mat