Default severity: info · Applicability: safe · Category: queryset
Detects qs.count() == 0 used to test for emptiness. Counting all matching rows just to compare against zero does far more work than asking the database whether at least one row exists — .exists() translates to SELECT 1 ... LIMIT 1, no row count required. The rewrite is semantically identical, so the QuickFix (“Rewrite to not .exists()”) is eligible for auto-apply and “Fix All”.
if Order.objects.filter(user=user).count() == 0:
show_empty_state()
if not Order.objects.filter(user=user).exists():
show_empty_state()
# orm-lens-disable-next-line DOL002
Or per-workspace in .vscode/settings.json: {"djangoOrmLens.rules": {"DOL002": "off"}}.