cleanerversion
cleanerversion copied to clipboard
Exception message verbosity for <model>.DoesNotExist exception
Exception message verbosity for related (and failed) lookups could be enhanced by adding the source object's type, identity and, if set, the querytime used for the lookup.
Note that the DoesNotExist class is bound to the related model's class.
So, the following code would raise an Article.DoesNotExist exception if no article is found:
class Journal(Versionable):
name = CharField(...)
class Article(Versionable):
name = CharField(...)
journal = VersionedForeignKey(Journal)
# ...some code happens here...
# Assume there's no current journal assigned to article, this would raise a Journal.DoesNotExist exception saying: "DoesNotExist: Journal matching query does not exist."
journal = article.journal