aboutsummaryrefslogtreecommitdiffstats
path: root/rest_framework/serializers.py
diff options
context:
space:
mode:
authorJosé Padilla2015-02-04 23:33:59 -0400
committerJosé Padilla2015-02-04 23:33:59 -0400
commit48fa77c09e2198c7877a724a46230caedcc7b529 (patch)
tree14364320e6358e32205b909c7b14a41b122a809b /rest_framework/serializers.py
parentb844cc4bb6b53e2bac4ce1351b22f44a82b7b937 (diff)
downloaddjango-rest-framework-48fa77c09e2198c7877a724a46230caedcc7b529.tar.bz2
Add child to ListField when using ArrayField
Diffstat (limited to 'rest_framework/serializers.py')
-rw-r--r--rest_framework/serializers.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/rest_framework/serializers.py b/rest_framework/serializers.py
index 520b9774..84e4961b 100644
--- a/rest_framework/serializers.py
+++ b/rest_framework/serializers.py
@@ -986,15 +986,25 @@ class ModelSerializer(Serializer):
# Fields with choices get coerced into `ChoiceField`
# instead of using their regular typed field.
field_class = ChoiceField
+
if not issubclass(field_class, ModelField):
# `model_field` is only valid for the fallback case of
# `ModelField`, which is used when no other typed field
# matched to the model field.
field_kwargs.pop('model_field', None)
+
if not issubclass(field_class, CharField) and not issubclass(field_class, ChoiceField):
# `allow_blank` is only valid for textual fields.
field_kwargs.pop('allow_blank', None)
+ if postgres_fields and isinstance(model_field, postgres_fields.ArrayField):
+ child_model_field = model_field.base_field.base_field
+ child_field_class, child_field_kwargs = self.build_standard_field(
+ 'child', child_model_field
+ )
+
+ field_kwargs['child'] = child_field_class(**child_field_kwargs)
+
return field_class, field_kwargs
def build_relational_field(self, field_name, relation_info):