diff options
| author | Tom Christie | 2014-12-12 15:37:43 +0000 |
|---|---|---|
| committer | Tom Christie | 2014-12-12 15:37:43 +0000 |
| commit | baaa356489dd51d7c68161db40e99cd59b1124c3 (patch) | |
| tree | 23dc5c4cbe1065580ff88ddd1bfa6dcda956ac68 /rest_framework/utils/field_mapping.py | |
| parent | 5e6052811716a494e995a84c497579867ee6acaa (diff) | |
| parent | fd473aa905337908b41c9a1087967a19f0558f89 (diff) | |
| download | django-rest-framework-baaa356489dd51d7c68161db40e99cd59b1124c3.tar.bz2 | |
Merge master
Diffstat (limited to 'rest_framework/utils/field_mapping.py')
| -rw-r--r-- | rest_framework/utils/field_mapping.py | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/rest_framework/utils/field_mapping.py b/rest_framework/utils/field_mapping.py index 9c187176..fca97b4b 100644 --- a/rest_framework/utils/field_mapping.py +++ b/rest_framework/utils/field_mapping.py @@ -59,7 +59,7 @@ def get_field_kwargs(field_name, model_field): Creates a default instance of a basic non-relational field. """ kwargs = {} - validator_kwarg = model_field.validators + validator_kwarg = list(model_field.validators) # The following will only be used by ModelField classes. # Gets removed for everything else. @@ -91,18 +91,18 @@ def get_field_kwargs(field_name, model_field): if model_field.has_default() or model_field.blank or model_field.null: kwargs['required'] = False - if model_field.flatchoices: - # If this model field contains choices, then return early. - # Further keyword arguments are not valid. - kwargs['choices'] = model_field.flatchoices - return kwargs - if model_field.null and not isinstance(model_field, models.NullBooleanField): kwargs['allow_null'] = True if model_field.blank: kwargs['allow_blank'] = True + if model_field.flatchoices: + # If this model field contains choices, then return early. + # Further keyword arguments are not valid. + kwargs['choices'] = model_field.flatchoices + return kwargs + # Ensure that max_length is passed explicitly as a keyword arg, # rather than as a validator. max_length = getattr(model_field, 'max_length', None) |
