On Thursday, March 27, 2014 3:10:13 AM UTC+2, Russell Keith-Magee wrote: > > In my ideal world, the get(default=None) approach would be what we would > do; but, as others have pointed out, default is a valid column name, so > this option isn't available to us. We already have a shortcut for > get_object_or_404; a matching get_object_or_none makes sense to me, and > puts the API where it make sense to me - as a shortcut for someone who is > repeating the "catch DoesNotExist" pattern regularly and wants an easier > way. >
Actually I think we could use .get(default=None). The way to do this is: 1. Deprecate direct use of .get(default=lookup_value), instead ask users to do .get(Q(default=lookup_value)). 2. After deprecation, add support for .get(default=default_if_no_match_value) This is somewhat confusing API - if you have a column named default, users *will* try to do .get(default=lookup_value), no matter how much we document this special case. OTOH I don't believe having field named default is that common. Another similar idea is to add support for .get(__default=None). One can't have a field named __default, or at least it won't work in any sane way with the ORM. Any support for these ideas? - Anssi -- You received this message because you are subscribed to the Google Groups "Django developers" 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 http://groups.google.com/group/django-developers. To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/3cc0d818-f02b-4659-b611-3b36c7e8ff99%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
