Answer the question
In order to leave comments, you need to log in
How to do a search in django?
for example, in the database there is a field that has a granite value in the form of
"one two three"; "one"; "two"; "three"; "two three"; "one three"; "one two"; "three two one" i.e. in any combination and separated by a space.
I receive data from the client in the form "one two three" or [one, two, three]
I need to exclude all records where the data is mentioned at least once.
I do
coun_id = request.GET.get('coun', None)
bl = request.GET.getlist('bl[]', None)
if coun_id and bl:
coun = Count.objects.get(id=coun_id)
b = ' '.join(bl)
snippets = Model.objects.filter(test=count) \
.exclude(Q(list__in=bl) | \
Q(list__istartswith=b) | \
Q(list__endswith=b) | \
Q(list__icontains=b) | \
Q(list__in=b))[:300]
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question