On Thu, Oct 11, 2012 at 2:00 PM, Marijonas Petrauskas <marp...@gmail.com> wrote: > You can use: > > obj = next(iter(SomeModel.objects.filter(foo='bar')), None) > > The 'iter' part is not particularly elegant, but it's the only one-liner > known to me. >
obj, = SomeModel.objects.filter(foo='bar') or [None] but we're getting deep into django-users land. D. -- You received this message because you are subscribed to the Google Groups "Django developers" group. 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.