#27242: Add get_object_or_none to django.shortcuts
     Reporter:  arogachev     |      Owner:  nobody
         Type:  New feature   |     Status:  new
    Component:  Core (Other)  |    Version:  master
     Severity:  Normal        |   Keywords:  object, model, shortcut
 Triage Stage:  Unreviewed    |  Has patch:  0
Easy pickings:  0             |      UI/UX:  0
 I think quite often we need to find object of certain model and return
 `None` if it does not exist. I suggest to add this to `django.shortcuts`:

 def get_object_or_none(klass, *args, **kwargs):
     queryset = _get_queryset(klass)
         return queryset.get(*args, **kwargs)
     except queryset.model.DoesNotExist:
         return None

 Yes, we can easily create this in our own code, but maybe consider to add
 this to the core?

Ticket URL: <https://code.djangoproject.com/ticket/27242>
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 django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
For more options, visit https://groups.google.com/d/optout.

Reply via email to