In Django documentation https://docs.djangoproject.com/en/dev/ref/forms/validation/#raising-validationerror said that it is good practice to prodive error code while raising
Take a look at ValidationError definition in django src, it's used as a convenient way to pass additional identifier (similar to e.errno
in standard python exception), you can use it like this:
try:
...
raise ValidationError(u'Oops', code=0x800)
...
except ValidationError as e:
print "Error code: ", e.code