Hi!

What do people think of

  A.objects.getdefault(slug="hello")  # returns None if slug doesn't exist
  A.objects.getdefault(slug="hello", default=A())  # returns empty object 
if slug doesn't exist

I find that in practice, most of the time it would be better to get None 
back instead of the DoesNotExist exception, but changing .get() is of 
course impossible without breaking the API.

I do think that

  A.objects.get(slug="hello", default=None)

is more elegant, but it might break some code. Although it does seem really 
unlikely anyone would add a field named "default" to their model and then 
use it to locate a unique object.

The only related info I found in the issue tracker and on this list was a 
thread from 2006.

Ole

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-developers/-/yt14RXkhAkwJ.
To post to this group, send email to django-developers@googlegroups.com.
To unsubscribe from this group, send email to 
django-developers+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-developers?hl=en.

Reply via email to