Last active
April 4, 2024 13:59
-
-
Save armando-herastang/7748a4228231693b68affc7d0f1c9223 to your computer and use it in GitHub Desktop.
Check whether a Django queryset has been evaluated or not
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.db.models import QuerySet | |
def is_qs_evaluated(qs: QuerySet) -> bool: | |
return getattr(qs, '_result_cache', None) is not None |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment