これは機能します:
class Right(ResponseMixin, View):
"""Right"""
renderers = (JSONRenderer, XMLRenderer)
def get(self, request, right_id):
if not right_id:
return self.render(
Response(status.HTTP_400_BAD_REQUEST,
{"successful": False})
)
これはしません:
class Right(ResponseMixin, View):
"""Right"""
renderers = (JSONRenderer, XMLRenderer)
# @default_json
def get(self, request, right_id):
if not right_id:
raise ErrorResponse(status.HTTP_400_BAD_REQUEST,
{"successful": False})
次のようなエラー メッセージが表示されます。
/v1/right/ の ErrorResponse 例外が提供されていません
または:
Environment:
Request Method: GET
Request URL: http://127.0.0.1:8000/v1/right/
Django Version: 1.4.1
Python Version: 2.7.2
Installed Applications:
('django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles')
Installed Middleware:
('api.disable.DisableCSRF',
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware')
Traceback:
File "/Users/agoodattitude/Envs/locker-proxy/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response
111. response = callback(request, *callback_args, **callback_kwargs)
File "/Users/agoodattitude/Envs/locker-proxy/lib/python2.7/site-packages/django/views/generic/base.py" in view
48. return self.dispatch(request, *args, **kwargs)
File "/Users/agoodattitude/Envs/locker-proxy/lib/python2.7/site-packages/django/views/generic/base.py" in dispatch
69. return handler(request, *args, **kwargs)
File "/Users/agoodattitude/saff-py/locker-proxy/locker_proxy/api/resources.py" in get
125. error_message="right_id was not passed."))
Exception Type: ErrorResponse at /v1/right/
Exception Value:
「例外が提供されていません」とはどういう意味ですか?
(注、複雑さを軽減するためにコードをわずかに変更しましたが、問題は残ります...)