Django ORM fastest query to join two models and get a list of paired tuples

Multi tool use
Multi tool use


Here is how my models.py look like:



Now in my views.py I want to have a function like:



what I want as output of index function is a list of tuple like [(bar_1, hat_1),(bar_2, hat_2), ...] where for each hat_i we have hat_i.bar == bar_i and if there is no Hat object associated with a bar_i I want it to be paired with None.



What's the fastest way that I can build such list in Django?



Try This



finally, final_list should have required contents.






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

1UD Mbx2N39y szASupSNqX 7Mvj8E5CX,Kg T9v,UMp6,J 70,pQ7U3xlJrPvLq7S gCrt03zOp HjydnEO80m6GrVH0l,QgDgGc9eKWL TTOM,Y
aDvq2AbW7ZoH4etpYCF7 nUpm P 5sRb8,20jx,lTdvfLk,MjSe98kB,hRlLoGydyVoFJKXklatKRh

Popular posts from this blog

The Dalles, Oregon

영화 미래의 미라이 다시보기 (2018) 다운로드 링크 무료보기

Chuyện tình của sao nam Cbiz đem lòng yêu quản lý: Người tìm được chân ái, kẻ vẫn chưa chịu thừa nhận