그래서 나는 다음과 같이 시작하는 쿼리를 만드는 중이라서. 그러면 Example
중 처음으로 연결된 객체가 모두 FooBar
이됩니다. 다른 필드는, target
, 이 구별되지 않습니다 말할 수 어디장고가 아닌 별개의 쿼리
만FooBar
객체를 포함하지만 여기 내 목표입니다.
target_ids = [] #holding a check list for comparison
correct_targets = [] #holding the objects I want to have
for item in queryset: #iteration
target_ids.append(item.example.pk) #send primary key to check list
if target_ids.count(item.example.pk) == 2: #check if there has been more than one (if there is more than two I don't send another correct target since I would have already sent it previously)
correct_targets.append(item) #send correct target
난을 반복 할 필요없이 내 queryset
에서 이러한 개체의 검색어 세트를 얻을 수있는 방법이있을 것이라고 기대했다 :
나는 다음과 같은 루프가 있다고 할 수 있습니다. 이것이 가능합니까?