Opened 10 years ago
Closed 10 years ago
#23500 closed New feature (worksforme)
Allow get_object_or_404 to accept select_related and prefetch_related
Reported by: | Abhin Chhabra | Owned by: | nobody |
---|---|---|---|
Component: | Utilities | Version: | dev |
Severity: | Normal | Keywords: | get_object_or_404 select_related prefetch_related |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
get_object_or_404 is a nice helper, but it doesn't support select_related and prefetch_related. At my company, we've had to implement that ourselves, but it would be great if Django had support for those to begin with.
I will totally be willing to create the patch myself, but I want to figure out whether there is support for this improvement. Please let me know if you approve of this change.
Note:
See TracTickets
for help on using tickets.
The first argument to
get_object_or_404
can be a model or manager or query set; therefore it supports all query set methods.