#34611: Support getting None in qs.get()
-------------------------------------+-------------------------------------
Reporter: Amin | Owner: nobody
Aminian |
Type: New | Status: new
feature |
Component: Database | Version: 4.2
layer (models, ORM) |
Severity: Normal | Keywords:
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
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.
--
Ticket URL: <https://code.djangoproject.com/ticket/34611>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/0107018870989986-64a9502c-9a8a-439a-892c-7ac47ee600d6-000000%40eu-central-1.amazonses.com.