[Django] #34435: JSONField with default='' raises warning "JSONField default should be a callable"

1 view
Skip to first unread message

Django

unread,
Mar 24, 2023, 7:36:31 AM3/24/23
to django-...@googlegroups.com
#34435: JSONField with default='' raises warning "JSONField default should be a
callable"
-----------------------------------------+------------------------
Reporter: Tobias Krönke | Owner: nobody
Type: Uncategorized | Status: new
Component: Uncategorized | Version: 4.1
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-----------------------------------------+------------------------
Hi! I have a model with this field:


{{{
message = models.JSONField(editable=False, default='')
}}}

When running

{{{
manage.py check
}}}

I receive a warning, that IMO should not be triggered:

{{{
message: (fields.E010) JSONField default should be a callable instead of
an instance so that it's not shared between all field instances.
HINT: Use a callable instead, e.g., use `dict` instead of `{}`.
}}}

django should check, if the default is mutable and only if so issue that
warning.

--
Ticket URL: <https://code.djangoproject.com/ticket/34435>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Reply all
Reply to author
Forward
0 new messages