I'm trying to get the error message for a field using a custom validation class on tastypie.
I used the code on Tastipye Documentation website (AwesomeValidation class) : http://django-tastypie.readthedocs.org/en/latest/validation.html#implementing-your-own-validation
Here's my ressource class :
class UserResource(ModelResource):
class Meta:
queryset = User.objects.all()
resource_name = 'user'
authorization = Authorization()
validation = AwesomeValidation()
I use slumber to try a POST request :
import slumber
api = slumber.API("127.0.0.1", auth=("auth", "auth"))
api.user.post({"username": "test", "password": "test", "password_confirm": "test", "email": "[email protected]"})
I get an Error 400, but no error message.
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/dist-packages/slumber/__init__.py", line 125, in post
resp = self._request("POST", data=s.dumps(data), params=kwargs)
File "/usr/local/lib/python2.7/dist-packages/slumber/__init__.py", line 104, in _request
raise exceptions.HttpClientError("Client Error %s: %s" % (resp.status_code, url), response=resp, content=resp.content)
slumber.exceptions.HttpClientError: Client Error 400: http://127.0.0.1:8000/api/v1/user/
Is there anything to do with the custom validation class to get the error message ?
Quoth your link:
Under this validation, every field that’s a string is checked for the word ‘awesome’. If it’s not in the string, it’s an error.