diff options
| author | Simon Charette <charette.s@gmail.com> | 2015-12-04 13:14:12 -0500 |
|---|---|---|
| committer | Simon Charette <charette.s@gmail.com> | 2015-12-07 15:04:13 -0500 |
| commit | c0da598077ea475e65741abbba6993e4677fe501 (patch) | |
| tree | 4e7e90f7e033c899c63f0d782f62c25897666faf /django/contrib/postgres/fields/array.py | |
| parent | 0154702a987bd06d20e53fe23284b2c4a93b9063 (diff) | |
[1.9.x] Fixed #25867 -- Fixed a system check crash with nested ArrayFields.
Thanks to Jean Gourds for the report, Tim and Claude for the review.
Backport of 59b57e672c2f5a685804cce253d2c5314c45c5fa from master
Diffstat (limited to 'django/contrib/postgres/fields/array.py')
| -rw-r--r-- | django/contrib/postgres/fields/array.py | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/django/contrib/postgres/fields/array.py b/django/contrib/postgres/fields/array.py index ff37483b4f..65f28672aa 100644 --- a/django/contrib/postgres/fields/array.py +++ b/django/contrib/postgres/fields/array.py @@ -29,9 +29,17 @@ class ArrayField(Field): self.default_validators.append(ArrayMaxLengthValidator(self.size)) super(ArrayField, self).__init__(**kwargs) - def contribute_to_class(self, cls, name, **kwargs): - super(ArrayField, self).contribute_to_class(cls, name, **kwargs) - self.base_field.model = cls + @property + def model(self): + try: + return self.__dict__['model'] + except KeyError: + raise AttributeError("'%s' object has no attribute 'model'" % self.__class__.__name__) + + @model.setter + def model(self, model): + self.__dict__['model'] = model + self.base_field.model = model def check(self, **kwargs): errors = super(ArrayField, self).check(**kwargs) |
