summaryrefslogtreecommitdiff
path: root/django/contrib/postgres/fields/jsonb.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/jsonb.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/jsonb.py')
-rw-r--r--django/contrib/postgres/fields/jsonb.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/django/contrib/postgres/fields/jsonb.py b/django/contrib/postgres/fields/jsonb.py
index a06187c4bc..4ed441003b 100644
--- a/django/contrib/postgres/fields/jsonb.py
+++ b/django/contrib/postgres/fields/jsonb.py
@@ -9,6 +9,8 @@ from django.db.models import (
)
from django.utils.translation import gettext_lazy as _
+from .mixins import CheckFieldDefaultMixin
+
__all__ = ['JSONField']
@@ -25,12 +27,13 @@ class JsonAdapter(Json):
return json.dumps(obj, **options)
-class JSONField(Field):
+class JSONField(CheckFieldDefaultMixin, Field):
empty_strings_allowed = False
description = _('A JSON object')
default_error_messages = {
'invalid': _("Value must be valid JSON."),
}
+ _default_hint = ('dict', '{}')
def __init__(self, verbose_name=None, name=None, encoder=None, **kwargs):
if encoder and not callable(encoder):