[Answer]-Raising validation error in django form for the api

1👍

You might want to have a look in the form’s is_valid() method: https://docs.djangoproject.com/en/dev/ref/forms/api/#django.forms.Form.is_valid

For example

if registrationform.is_valid():
   //do your stuff
   ....
   register['error'] = False
else:
   //return the errors
   registerUser['message'] = _('Oops! Please fix the following errors')
   register['error'] = True
   register['errors'] = registrationform.errors
   ....

Leave a comment