diff options
| author | Tom Christie | 2012-10-09 09:57:08 +0100 | 
|---|---|---|
| committer | Tom Christie | 2012-10-09 09:57:08 +0100 | 
| commit | beea6487b214a0e40e0688a511cce5e065568632 (patch) | |
| tree | e80d8f33cbd5a530109f1c1a0b91a0286346896e | |
| parent | 65f592866c5cd5103e99ed453543807bcbdaa9da (diff) | |
| download | django-rest-framework-beea6487b214a0e40e0688a511cce5e065568632.tar.bz2 | |
Function based views get proper naming in browseable API
| -rw-r--r-- | rest_framework/decorators.py | 2 | ||||
| -rw-r--r-- | rest_framework/views.py | 3 | 
2 files changed, 4 insertions, 1 deletions
diff --git a/rest_framework/decorators.py b/rest_framework/decorators.py index 0c5fec55..2adbff24 100644 --- a/rest_framework/decorators.py +++ b/rest_framework/decorators.py @@ -21,6 +21,8 @@ def api_view(http_method_names):          for method in http_method_names:              setattr(WrappedAPIView, method.lower(), handler) +        WrappedAPIView.__name__ = func.__name__ +          WrappedAPIView.renderer_classes = getattr(func, 'renderer_classes',                                                    APIView.renderer_classes) diff --git a/rest_framework/views.py b/rest_framework/views.py index 790c76fa..2c940dac 100644 --- a/rest_framework/views.py +++ b/rest_framework/views.py @@ -50,7 +50,8 @@ def _camelcase_to_spaces(content):      Used when generating names from view classes.      """      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):  | 
