When I do a lookup in dictionaries, I frequently use dict.get() so that it won't raise an exception if the key is missing. Even better, I can specify a default value when the key doesn't exist.
Is there an equivalent for Django querysets? It seems like the best I can do is this--
try:
author = Book.objects.get(title='Hamlet').author
except Book.DoesNotExist:
author = None
Makes sense, but I'm wondering if there is a more elegant way.