Reputation: 15610
I have an object variable obj
. Is it possible to check whether its a Queryset or not?
Upvotes: 26
Views: 13648
Reputation: 946
You can get the type of obj by python's inbuilt type()
Try this :
type(obj)
It will return as below if its a Queryset
<class 'django.db.models.query.QuerySet'>
Upvotes: 5
Reputation: 7366
You can use python built-in function isinstance.
from django.db.models.query import QuerySet
isinstance(your_qs, QuerySet)
Upvotes: 57