#34715 closed New feature (duplicate)

have proposal to create new orm method get_object_or_none same as get_object_or_404

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 Mahavir Agrawal)

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 (3)

comment:1 by Mahavir Agrawal, 17 months ago

Description: modified (diff)

comment:2 by Mahavir Agrawal, 17 months ago

Description: modified (diff)

comment:3 by Mariusz Felisiak, 17 months ago

Has patch: unset
Resolution: duplicate
Status: newclosed

Duplicate of #2659.

Note: See TracTickets for help on using tickets.
Back to Top