Opened 14 years ago
Closed 14 years ago
#16543 closed New feature (needsinfo)
Add an option to select_related to include OneToOneFields in depth-based search
| Reported by: | mnbayazit | Owned by: | nobody |
|---|---|---|---|
| Component: | Database layer (models, ORM) | Version: | 1.3 |
| Severity: | Normal | Keywords: | |
| Cc: | Triage Stage: | Unreviewed | |
| Has patch: | no | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description
I've got a very complicated "Shipment" model that contains many foreign keys, and those foreign keys have more and more foreign keys. The Shipment model also points to 3 separate users which of course have profiles. I need to display *all* this information on a page, but it would be quite tedious to explicitly list out every model I want joined when I do my query just so that I can have it pre-fetch the profiles for me.
Can we add a special include_onetoonefields option that will work with the depth option?
I'm sorry, but I don't understand the problem in your example.
What's wrong with
.select_related(depth=2)?