#36076: Raise a check error if null=False and default=None
-------------------------------------+-------------------------------------
Reporter: Csirmaz Bendegúz | Owner: (none)
Type: New feature | Status: closed
Component: Database layer | Version: dev
(models, ORM) |
Severity: Normal | Resolution: wontfix
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Jacob Walls):
My apologies for confusing things a little bit here.
> If part of the proposal was to use a NOT_PROVIDED sentinel for the
default value of default=
Well that's exactly what Django does, don't know why I seemed to think
this morning that wasn't the case 🤦 ️
With that confession out of the way, it still strikes me that this should
be sounded out on the forum to move it forward. To me, requiring `Field()`
over `Field(default=None)` feels like a code-style convention for a
linter, not a misconfiguration for a system check. Asking developers to
prefer one over the other requires knowing that there is a difference,
namely the `NOT_PROVIDED` sentinel, which we would also need to document.
I think teaching this to users could be avoided.
(I also noticed while grepping test models for `default=None` that was
discussed in the context of a check on the postgres `ArrayField` and was
[
https://github.com/django/django/pull/8930#discussion_r134115086
rejected] albeit without much discussion.)
--
Ticket URL: <
https://code.djangoproject.com/ticket/36076#comment:6>