diff options
author | Marc Tamlyn <marc.tamlyn@gmail.com> | 2014-07-15 12:30:34 +0100 |
---|---|---|
committer | Marc Tamlyn <marc.tamlyn@gmail.com> | 2014-07-29 10:37:11 +0100 |
commit | ef9f109013adc6e140c1a71d874aa88e893657b7 (patch) | |
tree | e90689eb21ddd1df2cbe81e41544a9b0c2de8eca /django/contrib/postgres/fields/array.py | |
parent | e5619330e2d3bf901155e98ef3fa7d224b6a260a (diff) | |
download | django-ef9f109013adc6e140c1a71d874aa88e893657b7.tar.gz |
Fixed #22962 -- Default values for ArrayField with migrations.
Fields normally try to force the default value to a string. As
translatable strings are not valid default values for ArrayField, we can
remove this behaviour which was causing issues with some migrations.
Thanks to @schinckel for the report.
Diffstat (limited to 'django/contrib/postgres/fields/array.py')
-rw-r--r-- | django/contrib/postgres/fields/array.py | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/django/contrib/postgres/fields/array.py b/django/contrib/postgres/fields/array.py index 772ab9e586..dea9c0440d 100644 --- a/django/contrib/postgres/fields/array.py +++ b/django/contrib/postgres/fields/array.py @@ -94,6 +94,14 @@ class ArrayField(Field): value = [self.base_field.to_python(val) for val in vals] return value + def get_default(self): + """Overridden from the default to prevent string-mangling.""" + if self.has_default(): + if callable(self.default): + return self.default() + return self.default + return '' + def value_to_string(self, obj): values = [] vals = self._get_val_from_obj(obj) |