On Thursday 13 March 2014 14:34:18 Josh Smeaton wrote: > +1 on get_or_none. It seems to be a pattern that comes up quite a lot in > user code, and I know I've had use for it lots of times.
Since 1.6, you should just be using first(). Compared to the try-get-except-DoesNotExist-return-None pattern, it is only missing the validation that there is, indeed, at most one objet matching the criteria. In a large majority of the cases I've seen, that validation is nice to have if it comes for free, but not worth a special effort, because it is taken care of by database constraints (in a significant part, the criteria just select by pk). I would be happy to have a validating first(), but the current proposition, as far as I understand, just overlaps existing API almost completely. I wouldn't veto it, but a strong -0 from me. Shai. -- 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/1857272.IFIdcI8OYn%40deblack. For more options, visit https://groups.google.com/d/optout.
