diff options
| author | Rense VanderHoek | 2015-02-20 16:31:12 +0100 | 
|---|---|---|
| committer | Rense VanderHoek | 2015-02-20 16:31:12 +0100 | 
| commit | c8609ba652e1752e690c9e27e02b3531589d0c2c (patch) | |
| tree | df496b7117d12f80b84d5663e84979a6fad479cc /rest_framework/metadata.py | |
| parent | dc8cc8607763fccc6eb3668ea7e2a976c08dd614 (diff) | |
| download | django-rest-framework-c8609ba652e1752e690c9e27e02b3531589d0c2c.tar.bz2 | |
Set field length/values as actual attributes.
The SimpleMetadata class in metadata.py tries to getattr() attributes
on a field. For this to work, max_length and min_length have to be
actually set as an attribute.
Did the same for min_value and max_value and added those two to
SimpleMetadata.get_field_info
Diffstat (limited to 'rest_framework/metadata.py')
| -rw-r--r-- | rest_framework/metadata.py | 8 | 
1 files changed, 7 insertions, 1 deletions
| diff --git a/rest_framework/metadata.py b/rest_framework/metadata.py index 3b058fab..bf3611aa 100644 --- a/rest_framework/metadata.py +++ b/rest_framework/metadata.py @@ -115,7 +115,13 @@ class SimpleMetadata(BaseMetadata):          field_info['type'] = self.label_lookup[field]          field_info['required'] = getattr(field, 'required', False) -        for attr in ['read_only', 'label', 'help_text', 'min_length', 'max_length']: +        attrs = [ +            'read_only', 'label', 'help_text', +            'min_length', 'max_length', +            'min_value', 'max_value' +        ] + +        for attr in attrs:              value = getattr(field, attr, None)              if value is not None and value != '':                  field_info[attr] = force_text(value, strings_only=True) | 
