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.
Related Contents:
- Django rest framework, use different serializers in the same ModelViewSet
- Pass request context to serializer from Viewset in Django Rest Framework
- context in nested serializers django rest framework
- Circular dependency in Django Rest Framework serializers
- Django REST framework: non-model serializer
- What are the differences between django-tastypie and djangorestframework? [closed]
- Django Rest Framework remove csrf
- When to use Serializer’s create() and ModelViewset’s perform_create()
- How to change field name in Django REST Framework
- Token Authentication for RESTful API: should the token be periodically changed?
- Django: TemplateDoesNotExist (rest_framework/api.html)
- Django REST Framework custom fields validation
- Django Rest Framework with ChoiceField
- Django rest framework nested self-referential objects
- How do you filter a nested serializer in Django Rest Framework?
- Write only, read only fields in django rest framework
- RuntimeError: Model class django.contrib.sites.models.Site doesn’t declare an explicit app_label and isn’t in an application in INSTALLED_APPS
- Django REST framework serializer without a model
- Aggregate (and other annotated) fields in Django Rest Framework serializers
- How to set current user to user field in Django Rest Framework?
- How Can I Disable Authentication in Django REST Framework
- Authorization Credentials Stripped — django, elastic beanstalk, oauth
- Django Rest Framework: Disable field update after object is created
- Django test RequestFactory vs Client
- Django Rest framework, how to include ‘__all__’ fields and a related field in ModelSerializer ?
- django-rest-framework 3.0 create or update in nested serializer
- Django REST Framework combining routers from different apps
- Capture parameters in django-rest-framework
- Django Rest Framework, passing parameters with GET request, classed based views
- Additional field while serializing django rest framework
- Is it possible to use FastAPI with Django?
- Serializing a list of objects with django-rest-framework
- Exclude a field from django rest framework serializer
- How to programmatically call a Django Rest Framework view within another view?
- Django REST Framework viewset per-action permissions
- Editing django-rest-framework serializer object before save
- Django Rest Framework – Get related model field in serializer
- Django rest framework – filtering for serializer field
- Django Rest Framework writable nested serializers
- Why does Django Rest Framework discourage model level validation?
- Turn off automatic pagination of Django Rest Framework ModelViewSet
- Custom error messages in Django Rest Framework serializer
- Django testing rest-framework: APIRequestFactory vs APIClient
- django rest framework – how do you flatten nested data?
- How to make a POST simple JSON using Django REST Framework? CSRF token missing or incorrect
- Django: Rest Framework authenticate header
- How can I make a trailing slash optional on a Django Rest Framework SimpleRouter
- What’s the differences between has_object_permission and has_permission?
- Django Rest Framework update field
- This QueryDict instance is immutable