mirror of https://github.com/django/django.git
Fixed #25226 -- Set the model attribute on ArrayField's base_field
This commit is contained in:
parent
244404227e
commit
520802160a
|
@ -28,6 +28,10 @@ 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
|
||||
|
||||
def check(self, **kwargs):
|
||||
errors = super(ArrayField, self).check(**kwargs)
|
||||
if self.base_field.remote_field:
|
||||
|
|
|
@ -97,6 +97,12 @@ class TestSaveLoad(PostgreSQLTestCase):
|
|||
self.assertEqual(instance.uuids, loaded.uuids)
|
||||
self.assertEqual(instance.decimals, loaded.decimals)
|
||||
|
||||
def test_model_set_on_base_field(self):
|
||||
instance = IntegerArrayModel()
|
||||
field = instance._meta.get_field('field')
|
||||
self.assertEqual(field.model, IntegerArrayModel)
|
||||
self.assertEqual(field.base_field.model, IntegerArrayModel)
|
||||
|
||||
|
||||
class TestQuerying(PostgreSQLTestCase):
|
||||
|
||||
|
|
Loading…
Reference in New Issue