add exclude method on QuerySet and fix missing default values on creation
This commit is contained in:
@ -165,6 +165,18 @@ async def test_model_filter():
|
||||
products = await Product.objects.all(name__icontains="T")
|
||||
assert len(products) == 2
|
||||
|
||||
products = await Product.objects.exclude(rating__gte=4).all()
|
||||
assert len(products) == 1
|
||||
|
||||
products = await Product.objects.exclude(rating__gte=4, in_stock=True).all()
|
||||
assert len(products) == 2
|
||||
|
||||
products = await Product.objects.exclude(in_stock=True).all()
|
||||
assert len(products) == 1
|
||||
|
||||
products = await Product.objects.exclude(name__icontains="T").all()
|
||||
assert len(products) == 1
|
||||
|
||||
# Test escaping % character from icontains, contains, and iexact
|
||||
await Product.objects.create(name="100%-Cotton", rating=3)
|
||||
await Product.objects.create(name="Cotton-100%-Egyptian", rating=3)
|
||||
|
||||
Reference in New Issue
Block a user