Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Also worth looking at prefetch_related(), which landed in 1.4, which can be used to alleviate common O(n) situations:

https://docs.djangoproject.com/en/dev/ref/models/querysets/#...

I've also used this in the past to do something similar, grabbing the ids of all specified related fields (related to the same model type) and pulling them back in a single query, with the option to only grab certain columns as dicts instead of full model instances if you're only selecting additional data required for specific templates:

http://djangosnippets.org/snippets/1117/



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: