参考资料
https://www.codegrepper.com/code-examples/python/django+exists+query
pass in queryset as filter django
users = UserClasses.objects.filter(class_id=data['class_id'])
user_details = User.objects.filter(id__in=users.values_list('id', flat=True))
django queryset exists
if some_queryset.exists():
print("There is at least one object in some_queryset")