summaryrefslogtreecommitdiff
path: root/django/contrib/postgres/fields/array.py
diff options
context:
space:
mode:
authorFlávio Juvenal <flaviojuvenal@gmail.com>2017-08-17 16:21:35 -0700
committerTim Graham <timograham@gmail.com>2017-10-20 13:17:22 -0400
commitf6e1789654e82bac08cead5a2d2a9132f6403f52 (patch)
treeabc80ed75f7c67ac7e44125e25c9898ff89fd68b /django/contrib/postgres/fields/array.py
parent5ceaf14686ce626404afb6a5fbd3d8286410bf13 (diff)
downloaddjango-f6e1789654e82bac08cead5a2d2a9132f6403f52.tar.gz
Fixed #28577 -- Added checks for ArrayField and JSONField to prevent mutable defaults.
Diffstat (limited to 'django/contrib/postgres/fields/array.py')
-rw-r--r--django/contrib/postgres/fields/array.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/django/contrib/postgres/fields/array.py b/django/contrib/postgres/fields/array.py
index 7992740663..5c9bb1b2ee 100644
--- a/django/contrib/postgres/fields/array.py
+++ b/django/contrib/postgres/fields/array.py
@@ -10,17 +10,19 @@ from django.utils.inspect import func_supports_parameter
from django.utils.translation import gettext_lazy as _
from ..utils import prefix_validation_error
+from .mixins import CheckFieldDefaultMixin
from .utils import AttributeSetter
__all__ = ['ArrayField']
-class ArrayField(Field):
+class ArrayField(CheckFieldDefaultMixin, Field):
empty_strings_allowed = False
default_error_messages = {
'item_invalid': _('Item %(nth)s in the array did not validate: '),
'nested_array_mismatch': _('Nested arrays must have the same length.'),
}
+ _default_hint = ('list', '[]')
def __init__(self, base_field, size=None, **kwargs):
self.base_field = base_field