In Django, how can I get an exception's message?
ValidationError
actually holds multiple error messages.
The output of print err
is [u'Empty URL']
because that is the string returned by repr(err.messages)
(see ValidationError.__str__
source code).
If you want to print a single readable message out of a ValidationError
, you can concatenate the list of error messages, for example:
# Python 2
print '; '.join(err.messages)
# Python 3
print('; '.join(err.messages))