57👍
✅
You can use python built-in function isinstance.
from django.db.models.query import QuerySet
isinstance(your_qs, QuerySet)
4👍
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'>
- [Django]-Itertools.groupby in a django template
- [Django]-How do you return 404 when resource is not found in Django REST Framework
- [Django]-How can I define a list field in django rest framework?
Source:stackexchange.com