Opened 23 hours ago

Last modified 5 hours ago

#36076 closed New feature

Raise a check error if null=False and default=None — at Version 1

Reported by: Csirmaz Bendegúz Owned by:
Component: Database layer (models, ORM) Version: dev
Severity: Normal Keywords:
Cc: Csirmaz Bendegúz Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no

Description (last modified by Csirmaz Bendegúz)

If a field has null=False Django shouldn't allow setting default=None or db_default=None.

class Model(models.Model):
    text = models.TextField(default=None)

This will raise an IntegrityError on create.
It could be prevented with a system check.
Same applies to db_default.

Change History (1)

comment:1 by Csirmaz Bendegúz, 23 hours ago

Description: modified (diff)
Easy pickings: set
Owner: Csirmaz Bendegúz removed
Status: assignednew

I think this is an easy win if someone else wants to work on it?

Note: See TracTickets for help on using tickets.
Back to Top