@@ -986,15 +986,25 @@ def build_standard_field(self, field_name, model_field):
986
986
# Fields with choices get coerced into `ChoiceField`
987
987
# instead of using their regular typed field.
988
988
field_class = ChoiceField
989
+
989
990
if not issubclass (field_class , ModelField ):
990
991
# `model_field` is only valid for the fallback case of
991
992
# `ModelField`, which is used when no other typed field
992
993
# matched to the model field.
993
994
field_kwargs .pop ('model_field' , None )
995
+
994
996
if not issubclass (field_class , CharField ) and not issubclass (field_class , ChoiceField ):
995
997
# `allow_blank` is only valid for textual fields.
996
998
field_kwargs .pop ('allow_blank' , None )
997
999
1000
+ if postgres_fields and isinstance (model_field , postgres_fields .ArrayField ):
1001
+ child_model_field = model_field .base_field
1002
+ child_field_class , child_field_kwargs = self .build_standard_field (
1003
+ 'child' , child_model_field
1004
+ )
1005
+
1006
+ field_kwargs ['child' ] = child_field_class (** child_field_kwargs )
1007
+
998
1008
return field_class , field_kwargs
999
1009
1000
1010
def build_relational_field (self , field_name , relation_info ):
@@ -1337,6 +1347,7 @@ class CharMappingField(DictField):
1337
1347
child = CharField ()
1338
1348
1339
1349
ModelSerializer .serializer_field_mapping [postgres_fields .HStoreField ] = CharMappingField
1350
+ ModelSerializer .serializer_field_mapping [postgres_fields .ArrayField ] = ListField
1340
1351
1341
1352
1342
1353
class HyperlinkedModelSerializer (ModelSerializer ):
0 commit comments