title: Sending different errors depending on url Django
body: <p>I am working in Django and I have a situation where I have written a custom validator that lives in the model.py</p>
  
  <p>This validator should return a validationError when the input is bad.</p>
  
  <p>In the project I am working on, we are using Django Rest Framework for our API and the Django admin panel for our admin panel. They connect to the same DB</p>
  
  <p>My problem is that when the request comes from the API I need to return a 'serializers.ValidationError' (which contains a status code of 400), but when the request comes from the admin panel I want to return a 'django.core.exceptions.ValidationError' which works on the admin panel. The exceptions.ValidationError does not display correctly in the API and the serializers.ValidationError causes the admin panel to break. Is there some way I can send the appropriate ValidationError to the appropriate place?</p>
  
  <p>here is my validation function (it lives in the model)</p>
  
  <pre><code> def validate_unique(self, *args, **kwargs):
      super(OrganizationBase, self).validate_unique(*args, **kwargs)
      qs = self.__class__._default_manager.filter(organization_type="MEMBER")
      if not self._state.adding and self.pk is not None:
          qs = qs.exclude(pk=self.pk)
      if qs.exists():
          raise serializers.ValidationError("Only one organization with \'Organization Type\' of \'Member\' is allowed.") #api
          raise exceptions.ValidationError("Only one organization with \'Organization Type\' of \'Member\' is allowed.") #admin
  </code></pre>
  
  <p>Those two lines at the end are the two errors written together for illustration's sake, in this case only the #api one would run</p>
  
  <p>Basically I want to send errorA when the request is coming from the admin panel and errorB when the request is coming from the API</p>
  
  <p>Thank you</p>