Search code examples
djangodjango-queryset

Check if an object is a QuerySet


I have an object variable obj. Is it possible to check whether its a Queryset or not?


Solution

  • You can use python built-in function isinstance.

    from django.db.models.query import QuerySet
    isinstance(your_qs, QuerySet)