what is diffrent between title and title_icontains in django ?
from .model import product
product.objects.filter(title='blah')
product.objects.filter(tite__icontains='blah')
CodePudding user response:
Probably it is title__icontains=… so with two consecutive underscores (__). In that case you make use of the __icontains lookup [Django-doc]. As the documentation says, this is a:
Case-insensitive containment test.
It thus looks for Products where the title contains blah. For example fooblah, blahfoo, of fooblahbar. It does this in a case insensitive manner, so products with FooBlah, BLAHfoo and FooBlAHBAR as title will also be retained.
CodePudding user response:
The first form ...filter(title='value') will return all objects whose title will match exactly the value.
And the second form, correctly written as ...filter(title__icontains) will return all objects whose title contains the value, but any upper/lower case letters will match.
The i here means "ignore case".
CodePudding user response:
tite__icontains is to look fo the string, but with case-insensitive.
