django rest framework: set field-level error from serializer validate() method

I figured it out, on this page of the documentation in the “BaseSerializer” section, there’s an example that shows ValidationError can take a dictionary argument upon initialization.

If I raise ValidationError({'field_val1': ['this field is not valid']}) I get the JSON response I want.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)