在"QuerySet"和"int"的实例之间不支持TypeError:“> ="
问题描述:
我只希望如果escs大于或等于 id(5),它将转到我的 if ,否则,将转到我的其他
I just want that if the escs is greater than or equal to id(5) it will go to my if , if not it will go to my else
studentenroll = StudentsEnrollmentRecord.objects.filter(Student_Users=args)
escs = esc.objects.filter(Education_Levels__in=studentenroll.values_list('ESC'))
if escs >= 5:
....
else:
....
这是我得到的错误
到目前为止,我尝试过的条件是如果escs> = 5:我已经尝试了这个如果escs.id> = 5:
What i tried so far is in my if condition if escs >= 5: ive tried this if escs.id >= 5:
这是错误
我错过了什么吗?
答
如果要检查是否存在大于或等于5的记录,可以使用以下语句:
If you want to check any record exist which has is greater than or equals 5, you can use following statement:
if esc.objects.filter(id__gte=5,Education_Levels__in=studentenroll.values_list('ESC')).exists():