开头的示例代码:
In my model:
class X(models.Model):
someField = models.ManyToManyField(Many_values, related_name='someField')
......
In my controller (which is a controller, not a view, get over it, Django!)
xes = X.objects.filter(iscool=True) [1]
.......
some_function_call(xes)
In some function:
for x in xes:
some_table.append(x.someField.first()) [2]
现在,有没有办法,强制执行django,在[1]时刻获得那些someField值(或者至少是第一个)?
现在,我将这些值存储在[2]的表中,其中:
简而言之,我想要达到的目标是:
每当我打电话
x.someField.first()
我希望它不要在数据库中查找。