在"QuerySet"和"int"的实例之间不支持TypeError:“> =" [英] TypeError: '>=' not supported between instances of 'QuerySet' and 'int'
本文介绍了在"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():
这篇关于在"QuerySet"和"int"的实例之间不支持TypeError:“> ="的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文