diff options
| author | Tom Christie | 2014-09-15 09:50:51 +0100 |
|---|---|---|
| committer | Tom Christie | 2014-09-15 09:50:51 +0100 |
| commit | 40dc588a372375608701f7e521dea6d860a49eb2 (patch) | |
| tree | a05cf7efe734cf12b6006272faf385ba467c653e /rest_framework/fields.py | |
| parent | afb28a44ad1737cd6fcd6da50ba9552f38293368 (diff) | |
| download | django-rest-framework-40dc588a372375608701f7e521dea6d860a49eb2.tar.bz2 | |
Drop label from serializer fields when not needed
Diffstat (limited to 'rest_framework/fields.py')
| -rw-r--r-- | rest_framework/fields.py | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/rest_framework/fields.py b/rest_framework/fields.py index 33ab0682..1818e705 100644 --- a/rest_framework/fields.py +++ b/rest_framework/fields.py @@ -80,6 +80,10 @@ def set_value(dictionary, keys, value): dictionary[keys[-1]] = value +def field_name_to_label(field_name): + return field_name.replace('_', ' ').capitalize() + + class SkipField(Exception): pass @@ -158,7 +162,7 @@ class Field(object): # `self.label` should deafult to being based on the field name. if self.label is None: - self.label = self.field_name.replace('_', ' ').capitalize() + self.label = field_name_to_label(self.field_name) # self.source should default to being the same as the field name. if self.source is None: |
