Re: Idea: Add .checked(/) to QuerySet as alternative to .filter() w/ .first()

2022-07-10 Thread 'Adam Johnson' via Django developers (Contributions to Django itself)
I'm also against adding get_or_none(), for the same reasons. Adding a method to shortcut something that can already be done doesn't seem worth it to me. On Sat, Jul 9, 2022 at 1:56 PM Mariusz Felisiak wrote: > I'm against it because it's already easily achievable and it's debatable > how it shou

Re: Idea: Add .checked(/) to QuerySet as alternative to .filter() w/ .first()

2022-07-10 Thread Dave Gaeddert
Fair enough. To me, the `get_or_none` behavior with multiple results would still be to raise an exception (so it is just like `get` in that sense). And that’s the reason I personally don’t just see it as a shortcut for `filter().first()` — I have (as I’m sure others have) made the mistake befor

Re: Idea: Add .checked(/) to QuerySet as alternative to .filter() w/ .first()

2022-07-10 Thread Matthias Kestenholz
Hi I believe the main objection is against adding additional API to querysets. get_object_or_404 only converts DoesNotExist into a 404 exception and doesn't handle MultipleObjectsReturned. I'm not the first to suggest adding an additional shortcut, e.g. django.shortcuts.get_object_or_none which w