Opened 3 years ago

Closed 3 years ago

#33384 closed New feature (duplicate)

Add QuerySet.get_or_none()

Reported by: MojixCoder Owned by: nobody
Component: Database layer (models, ORM) Version: 4.0
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 (last modified by MojixCoder)

In Django we have get method for getting model objects.
I have seen so many projects that implement get_or_none method in their projects.
There are also some python ORMs that have this feature for example tortoise-orm, ormar, peewee, etc.
I know that we have get_object_404 but sometimes we don't want to raise an exception.
so I think get_or_none would be kinda useful, what do you think?

Change History (4)

comment:1 by MojixCoder, 3 years ago

Summary: Add `get_or_none` methodAdd get_or_none method

comment:2 by MojixCoder, 3 years ago

Description: modified (diff)

comment:3 by MojixCoder, 3 years ago

Description: modified (diff)

comment:4 by Tim Graham, 3 years ago

Component: UncategorizedDatabase layer (models, ORM)
Resolution: duplicate
Status: newclosed
Summary: Add get_or_none methodAdd QuerySet.get_or_none()

Duplicate of #2659 and #11352, both of which were wontfixed.

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