diff options
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: |
