[Django] #33384: Add `get_or_none` method

13 views
Skip to first unread message

Django

unread,
Dec 25, 2021, 4:29:29 AM12/25/21
to django-...@googlegroups.com
#33384: Add `get_or_none` method
-----------------------------------------+------------------------
Reporter: MojixCoder | Owner: nobody
Type: New feature | Status: new
Component: Uncategorized | Version: 4.0
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-----------------------------------------+------------------------
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.
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?

--
Ticket URL: <https://code.djangoproject.com/ticket/33384>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Dec 25, 2021, 4:35:19 AM12/25/21
to django-...@googlegroups.com
#33384: Add get_or_none method
-------------------------------+--------------------------------------

Reporter: MojixCoder | Owner: nobody
Type: New feature | Status: new
Component: Uncategorized | Version: 4.0
Severity: Normal | Resolution:

Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------------------------

--
Ticket URL: <https://code.djangoproject.com/ticket/33384#comment:1>

Django

unread,
Dec 25, 2021, 5:48:18 AM12/25/21
to django-...@googlegroups.com
#33384: Add get_or_none method
-------------------------------+--------------------------------------
Reporter: MojixCoder | Owner: nobody
Type: New feature | Status: new
Component: Uncategorized | Version: 4.0
Severity: Normal | Resolution:

Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------------------------
Description changed by MojixCoder:

Old description:

> 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.
> 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?

New description:

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`, 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?

--

--
Ticket URL: <https://code.djangoproject.com/ticket/33384#comment:2>

Django

unread,
Dec 25, 2021, 5:58:36 AM12/25/21
to django-...@googlegroups.com
#33384: Add get_or_none method
-------------------------------+--------------------------------------
Reporter: MojixCoder | Owner: nobody
Type: New feature | Status: new
Component: Uncategorized | Version: 4.0
Severity: Normal | Resolution:

Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------------------------
Description changed by MojixCoder:

Old description:

> 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`, 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?

New description:

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?

--

--
Ticket URL: <https://code.djangoproject.com/ticket/33384#comment:3>

Django

unread,
Dec 25, 2021, 6:06:41 AM12/25/21
to django-...@googlegroups.com
#33384: Add QuerySet.get_or_none()
-------------------------------------+-------------------------------------
Reporter: MojixCoder | Owner: nobody
Type: New feature | Status: closed
Component: Database layer | Version: 4.0
(models, ORM) |
Severity: Normal | Resolution: duplicate

Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Tim Graham):

* status: new => closed
* resolution: => duplicate
* component: Uncategorized => Database layer (models, ORM)


Comment:

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

--
Ticket URL: <https://code.djangoproject.com/ticket/33384#comment:4>

Reply all
Reply to author
Forward
0 new messages