You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Django querysets can be used in a python boolean expression (ie: bool(qs) or if qs:), however in many cases this is considered a bad practice in django since the __bool__ method causes the whole queryset to be evaluated. The best practice suggests to use .exists() instead.
If possible, it would be very useful to have a check/test which warns against these usage.
The text was updated successfully, but these errors were encountered:
That's a great document. In fact, right below the passage you linked, it warns not to overuse exists(). So this check would really only be useful if it could tell with confidence that the queryset is not evaluated afterward.
Django querysets can be used in a python boolean expression (ie:
bool(qs)
orif qs:
), however in many cases this is considered a bad practice in django since the__bool__
method causes the whole queryset to be evaluated. The best practice suggests to use.exists()
instead.If possible, it would be very useful to have a check/test which warns against these usage.
The text was updated successfully, but these errors were encountered: