#36573: "fields.E010" should not warn when field defaults are expressions -------------------------------------+------------------------------------- Reporter: Clifford | Owner: Clifford Gama Gama | Type: | Status: assigned Cleanup/optimization | Component: Core | Version: dev (System checks) | Severity: Normal | Keywords: Triage Stage: | Has patch: 0 Unreviewed | Needs documentation: 0 | Needs tests: 0 Patch needs improvement: 0 | Easy pickings: 0 UI/UX: 0 | -------------------------------------+------------------------------------- The [https://github.com/django/django/blob/3e7aedfb2eb37d0c83ce3ce936f1b89eb5451dfa/django/db/models/fields/mixins.py#L40 CheckFieldDefaultMixin._check_default()] system check (fields.E010) currently warns whenever a field’s default is not None, and not callable. This is meant to prevent accidental sharing of mutable Python objects such as `[]` or `{}` across all model instances, however this also guards against expressions.
For example, it warns against using `data = models.JSONField(default=Value({"key": "value"}, JSONField()))` and has been warning for `Value(None, JSONField())`. This seems unnecessary, because (unless I’m missing something) expressions are not subject to the mutability/sharing problem that the check is meant to prevent. -- Ticket URL: <https://code.djangoproject.com/ticket/36573> Django <https://code.djangoproject.com/> The Web framework for perfectionists with deadlines. -- You received this message because you are subscribed to the Google Groups "Django updates" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-updates+unsubscr...@googlegroups.com. To view this discussion visit https://groups.google.com/d/msgid/django-updates/01070198e6be8858-faec1e31-677f-4b96-ae3d-8861937c3c41-000000%40eu-central-1.amazonses.com.