[Django] #34715: have proposal to create new orm method get_object_or_none same as get_object_or_404

6 views
Skip to first unread message

Django

unread,
Jul 16, 2023, 4:19:31 AM7/16/23
to django-...@googlegroups.com
#34715: have proposal to create new orm method get_object_or_none same as
get_object_or_404
-------------------------------------+-------------------------------------
Reporter: | Owner: nobody
mahavir2506 |
Type: New | Status: new
feature |
Component: Database | Version: 4.2
layer (models, ORM) |
Severity: Normal | Keywords: django orm
Triage Stage: | Has patch: 1
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 1
UI/UX: 0 |
-------------------------------------+-------------------------------------
want to contribute new method get_object_or_none
As django developer many developers are facing this issue some time they
want object and they also want if object doesn't exist tin that case
default they will get None object
because puting every time try except for this is very irritating so i want
to propose this function

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

Django

unread,
Jul 16, 2023, 4:21:42 AM7/16/23
to django-...@googlegroups.com
#34715: have proposal to create new orm method get_object_or_none same as
get_object_or_404
-------------------------------------+-------------------------------------
Reporter: mahavir2506 | Owner: nobody
Type: New feature | Status: new
Component: Database layer | Version: 4.2
(models, ORM) |
Severity: Normal | Resolution:

Keywords: django orm | Triage Stage:
| Unreviewed
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Description changed by mahavir2506:

Old description:

> want to contribute new method get_object_or_none
> As django developer many developers are facing this issue some time they
> want object and they also want if object doesn't exist tin that case
> default they will get None object
> because puting every time try except for this is very irritating so i
> want to propose this function

New description:

I want to contribute new method get_object_or_none
this method will be return object if object exist other wise this method
will return None

--

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

Django

unread,
Jul 16, 2023, 4:25:37 AM7/16/23
to django-...@googlegroups.com
#34715: have proposal to create new orm method get_object_or_none same as
get_object_or_404
-------------------------------------+-------------------------------------
Reporter: mahavir2506 | Owner: nobody
Type: New feature | Status: new
Component: Database layer | Version: 4.2
(models, ORM) |
Severity: Normal | Resolution:
Keywords: django orm | Triage Stage:
| Unreviewed
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Description changed by mahavir2506:

Old description:

> I want to contribute new method get_object_or_none


> this method will be return object if object exist other wise this method
> will return None

New description:

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.

--

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

Django

unread,
Jul 16, 2023, 6:13:10 AM7/16/23
to django-...@googlegroups.com
#34715: have proposal to create new orm method get_object_or_none same as
get_object_or_404
-------------------------------------+-------------------------------------
Reporter: mahavir2506 | Owner: nobody
Type: New feature | Status: closed

Component: Database layer | Version: 4.2
(models, ORM) |
Severity: Normal | Resolution: duplicate

Keywords: django orm | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

* status: new => closed
* has_patch: 1 => 0
* resolution: => duplicate


Comment:

Duplicate of #2659.

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

Reply all
Reply to author
Forward
0 new messages