I'd like a better fleshed out example from OP, as it seems trivial to implement yourself whenever you need it. It may be that I'm not understanding the suggestion.
On Wednesday, November 29, 2017 at 2:20:39 AM UTC-5, Sergey Fedoseev wrote: > > IMO it shouldn't be added to Django because the same thing can be done in > one line: get_object_or_404(qs[:1]), but we could add such using to > get_object_or_404() docs. > > On Wednesday, November 29, 2017 at 3:41:54 AM UTC+5, Piotr Domański wrote: >> >> Currently we have get_object_or_404 and get_list_or_404 but sometimes we >> just want to get first matching record for some criteria. >> If criteria aren't unique then get_object_or_404 raises >> MultipleObjectsReturned so request ends with internal server error. >> >> My idea is to add function which returns just first matching element and >> ends with 404 if no elements match. >> This function will have parameter order_by (optional or required) of type >> List['str'] >> which determines which element choose first if there are many matching >> elements. >> >> In my opinion addition of this feature is good idea, because it is useful >> and safe for Django framework. >> > -- You received this message because you are subscribed to the Google Groups "Django developers (Contributions to Django itself)" 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 https://groups.google.com/group/django-developers. To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/9df713de-2141-4a3e-91ab-141a6e8d47dd%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
