Hello,

I'm not sure this thread is going anywhere and I don't care either way.
If you've been reading up to this point...

... either you have too much spare time. Rather than rehashing this debate,
may I suggest triaging some tickets? That would really help!

https://docs.djangoproject.com/en/dev/internals/contributing/triaging-tickets/
https://code.djangoproject.com/query?status=!closed&stage=Unreviewed&desc=1&order=changetime

... or you really want this feature badly. I'll just leave this here:

from django.db.models.query import QuerySet
from django.db.models.manager import Manager

def queryset_get_or_none(self, *args, **kwargs):
    try:
        return self.get(*args, **kwargs)
    except self.model.DoesNotExist:
        pass

QuerySet.get_or_none = queryset_get_or_none

def manager_get_or_none(self, *args, **kwargs):
    return self.get_queryset().get_or_none(*args, **kwargs)

Manager.get_or_none = manager_get_or_none

(That kind of monkey-patching isn't the worst because even if
Django grows a method with that name, it will behave the same.)

-- 
Aymeric.

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/django-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/9AE24931-1E65-44C4-808E-AFD232B697C7%40polytechnique.org.
For more options, visit https://groups.google.com/d/optout.

Reply via email to