cleanerversion icon indicating copy to clipboard operation
cleanerversion copied to clipboard

Exception message verbosity for <model>.DoesNotExist exception

Open maennel opened this issue 9 years ago • 0 comments

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

maennel avatar Apr 07 '16 14:04 maennel