我有一个 for 循环,例如:
staff = Staff.objects.all().order_by('person__full_name')
for k in staff:
categ = k.staff_job_categories.all()[1]
if categ.name == unicode("xxx","utf-8"):
t = categ.name
但是因为categ = k.staff_job_categories.all()[1]
我从索引错误中得到了一个列表。
有任何想法吗?