Skip to content

Instantly share code, notes, and snippets.

@armando-herastang
Last active April 4, 2024 13:59
Show Gist options
  • Save armando-herastang/7748a4228231693b68affc7d0f1c9223 to your computer and use it in GitHub Desktop.
Save armando-herastang/7748a4228231693b68affc7d0f1c9223 to your computer and use it in GitHub Desktop.
Check whether a Django queryset has been evaluated or not
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