Opened 16 months ago
Last modified 16 months ago
#34715 closed New feature
have proposal to create new orm method get_object_or_none same as get_object_or_404 — at Version 2
Reported by: | Mahavir Agrawal | Owned by: | nobody |
---|---|---|---|
Component: | Database layer (models, ORM) | Version: | 4.2 |
Severity: | Normal | Keywords: | django orm |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | yes | UI/UX: | no |
Description (last modified by )
I would like to propose a new method called get_object_or_none, which would return an object if it exists, and None otherwise. This functionality is often desired by developers, as it eliminates the need to use try-except blocks and simplifies the code where developer wants object if exist otherwise None.
Change History (2)
comment:1 by , 16 months ago
Description: | modified (diff) |
---|
comment:2 by , 16 months ago
Description: | modified (diff) |
---|
Note:
See TracTickets
for help on using tickets.