I'm new to this... anybody know how the best way to push this forward? Or who can make a decision on whether something could/should be added to Django? I see some other tickets/discussions about basically the same thing: https://code.djangoproject.com/ticket/17546
A lot has changed in 10+ years... seems like this could be reconsidered. On Tuesday, June 28, 2022 at 9:27:52 AM UTC-5 Dave Gaeddert wrote: > > To begin with - thats the place I dont like .get() at all. The fact that > > it might end up with multiple objects is a nuisance, but we cannot do > > much about it for API compat reasons > > ... > > For what it's worth, I agree with what you're saying here too. Having a > `unique_or_none` (and maybe `unique`) with that field checking could be > cool, but in the interest of actually getting a change into Django, I > assume `get_or_none` without that behavior is a much easier place to start. > > On Sunday, June 26, 2022 at 2:07:34 PM UTC-5 j.bre...@netzkolchose.de > wrote: > >> Well from my own habits to use .get() only for unique filtering (>80% on >> pks only) I also see some benefit of a .get_or_none() variant - it would >> stop writing those exception handler wrappers over and over halfway >> during project realization. A ready-to-go official way would reduce that >> to a conditional expression from line one on. >> >> > .get_or_none() probably should allow to query only pks and >> > unique_together fields, so there will be no third state? >> >> To begin with - thats the place I dont like .get() at all. The fact that >> it might end up with multiple objects is a nuisance, but we cannot do >> much about it for API compat reasons. Idea - if we want such a changed >> behavior - maybe call it "unique_or_none()" to make the difference >> clear? If its called .get_or_none() imho it is better to stick to .get() >> behavior regarding multiple objects (still raising). >> > -- 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 django-developers+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/e21c2c22-5ba2-4421-8724-fa3f7e8f0b19n%40googlegroups.com.