title: Forms ValidationError and error code
body: <p>In Django documentation <a href="https://docs.djangoproject.com/en/dev/ref/forms/validation/#raising-validationerror" rel="noreferrer">https://docs.djangoproject.com/en/dev/ref/forms/validation/#raising-validationerror</a> said that it is good practice to prodive error code while raising ValidationError exception.</p>
  
  <pre><code># Good
  ValidationError(_('Invalid value'), code='invalid')
  
  # Bad
  ValidationError(_('Invalid value'))
  </code></pre>
  
  <p>I have API in my application and I'm using form to validate input data.<br/>
  If form is not valid, I whant to get these error codes (not error messages).<br/></p>
  
  <p>So I looked at source code of _clean_fields method of BaseForm:<br/>
  <a href="https://github.com/django/django/blob/master/django/forms/forms.py#L278" rel="noreferrer">https://github.com/django/django/blob/master/django/forms/forms.py#L278</a><br/></p>
  
  <pre><code>except ValidationError as e:
      self._errors[name] = self.error_class(e.messages)
      if name in self.cleaned_data:
          del self.cleaned_data[name]
  </code></pre>
  
  <p>As I understand this parameter (<code>self.code</code>) is not passed anywhere and can not be obtained after the form validation.</p>
  
  <p>Can someone explain what the purpose of using this error code?</p>