I have looked at this question but that doesn't really tell me about non-field errors.
My Model is:
class DeviceContact(models.Model):
created = models.DateTimeField(auto_now_add=True)
contact_sid = models.CharField(max_length=75, db_index=True)
contact_name = models.CharField(max_length=200)
contact_email = models.CharField(max_length=250, db_index=True)
contact_type = models.CharField(max_length=200, default='mobile')
class Meta:
unique_together = ("contact_sid", "contact_email", "contact_name")
class DeviceContactSerializer(serializers.ModelSerializer):
class Meta:
model = DeviceContact
fields = ('contact_sid', 'contact_name', 'contact_email', 'contact_type')
How do I return a custom error message when the unique_together
condition fails?