我正在尝试使用tastepie 上的自定义验证类获取字段的错误消息。
我在 Tastipye 文档网站(AwesomeValidation 类)上使用了代码:http: //django-tastypie.readthedocs.org/en/latest/validation.html#implementing-your-own-validation
这是我的资源类:
class UserResource(ModelResource):
class Meta:
queryset = User.objects.all()
resource_name = 'user'
authorization = Authorization()
validation = AwesomeValidation()
我使用休眠来尝试 POST 请求:
import slumber
api = slumber.API("127.0.0.1", auth=("auth", "auth"))
api.user.post({"username": "test", "password": "test", "password_confirm": "test", "email": "test@example.com"})
我收到错误 400,但没有错误消息。
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/
自定义验证类是否与获取错误消息有关?