title: Where should i do the django validations for objects and fields?
body: <p>I'm creating a django application which uses both the Django Rest Framework and the plain django-views as entrypoint for users.</p>
  
  <p>I want to do validation both independant fields of my models, and on objects on a whole. For example:</p>
  
  <ul>
  <li><p>Field: is the entered licence-plate a correct one based on a regex function. No relation to other fields.</p></li>
  <li><p>Object: Is the entered zipcode valid for the given country. Relates to zipcode and country in the model.</p></li>
  </ul>
  
  <p>For the DRF-API i use ModelSerializers which automatically call all the validators i have placed in my Model, for example:</p>
  
  <pre><code>class MyModel(models.Model):
      licence_plate = CharField(max_length=20, validators=[LicencePlateValidator])
  </code></pre>
  
  <p>Since the validator is given in the model, the API POSTS (because i use a ModelSerializer), as well as the objects created in the django admin backend are validated. </p>
  
  <p>But when i want to introduce object level validation i need to do that in the serializer's <strong>validate()</strong>-method, which means objects are only validated in the API.</p>
  
  <p>I'll have to override the model's save method too, to validate the objects created in the Django admin page. </p>
  
  <p><strong>Question:</strong> This seems a bit messy to me, is there a single point where i can put the object-level validators so that they are run at the API and in the admin-page, like i did with the field-level validation (I only have to put <em>them</em> in my model-declaration and everything is handled)</p>