Function based views get proper naming in browseable API

This commit is contained in:
Tom Christie 2012-10-09 09:57:08 +01:00
parent 65f592866c
commit beea6487b2
2 changed files with 4 additions and 1 deletions

View File

@ -21,6 +21,8 @@ def api_view(http_method_names):
for method in http_method_names: for method in http_method_names:
setattr(WrappedAPIView, method.lower(), handler) setattr(WrappedAPIView, method.lower(), handler)
WrappedAPIView.__name__ = func.__name__
WrappedAPIView.renderer_classes = getattr(func, 'renderer_classes', WrappedAPIView.renderer_classes = getattr(func, 'renderer_classes',
APIView.renderer_classes) APIView.renderer_classes)

View File

@ -50,7 +50,8 @@ def _camelcase_to_spaces(content):
Used when generating names from view classes. Used when generating names from view classes.
""" """
camelcase_boundry = '(((?<=[a-z])[A-Z])|([A-Z](?![A-Z]|$)))' camelcase_boundry = '(((?<=[a-z])[A-Z])|([A-Z](?![A-Z]|$)))'
return re.sub(camelcase_boundry, ' \\1', content).strip() content = re.sub(camelcase_boundry, ' \\1', content).strip()
return ' '.join(content.split('_')).title()
class APIView(View): class APIView(View):