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_
Is there a different between get_first_or_none() and the already existing
first()?
If we do first, some may want get_last_*() for everything too :)
On Tue, Nov 28, 2017 at 8:31 PM, Josh Smeaton
wrote:
> From my experiences, all projects I've worked on have implemented
> get_first_or_none and ge
>From my experiences, all projects I've worked on have implemented
get_first_or_none and get_first_or_404, and usually slightly differently. I
think these shortcuts would make sense for Django. Interested to hear how
common the usage would be from others on the list though.
--
You received thi
A quick search reveals a gist that contains a number of similar helpers.
https://gist.github.com/stkrp/47c536b681082c638849e9a89f77ff05
I think the main problem of going down this path is deciding which are
suitable to add and which aren't. I'm not sure that any of them meet the
"80% of projects
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