Default severity: info · Applicability: safe · Category: queryset
Detects qs.first() is None used as an emptiness test. .first() orders the queryset and fetches a full row — all columns, deserialized into a model instance — only for the result to be thrown away by the is None comparison. .exists() only asks the database whether a row is there. If you actually need the object afterwards, keep .first() and reuse the instance instead; this rule targets the case where the fetched row is discarded. The QuickFix (“Rewrite to not .exists()”) is safe to auto-apply.
if Subscription.objects.filter(user=user).first() is None:
prompt_upgrade()
if not Subscription.objects.filter(user=user).exists():
prompt_upgrade()
# orm-lens-disable-next-line DOL003
Or per-workspace in .vscode/settings.json: {"djangoOrmLens.rules": {"DOL003": "off"}}.