#34611 closed New feature (duplicate)

Support getting None in qs.get()

Reported by: Amin Aminian Owned by: nobody
Component: Database layer (models, ORM) Version: 4.2
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

The get() method in Queryset class would raise self.model.DoesNotExist exception if no records found for the params.

In cases that we don't want to handle exception and we don't want to use try...except, we use something like this:

qs.filter(...).first()

Which would return None and then there is no need to handle excpetion.

Can't we have it in get method itself ? I mean something like get(raise_exception=False) to return None instead of raising exception.

Change History (1)

comment:1 by Mariusz Felisiak, 11 months ago

Resolution: duplicate
Status: newclosed

Thanks for the report, however it was discussed and rejected multiple times, e.g. #2659 or #11352.

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