Opened 7 years ago

Last modified 7 years ago

#27955 closed Bug

JSONField.default not applied in admin — at Version 1

Reported by: Jannis Vajen Owned by: nobody
Component: contrib.admin Version: 1.10
Severity: Normal Keywords: JSONField, admin
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by Jannis Vajen)

Consider a model like this:

class Example(models.Model):
    json = JSONField(
        default=list,
        blank=True
    )

Creating an object programmatically works and applies the default value just fine. Saving an object with an empty value for the JSONField triggers an IntegrityError because Django tries to save an object with null instead of the default.

I'm not sure whether this ticket is a duplicate of https://code.djangoproject.com/ticket/27697 but I think this issue with the ignored default may have a different origin.

Change History (1)

comment:1 by Jannis Vajen, 7 years ago

Description: modified (diff)
Note: See TracTickets for help on using tickets.
Back to Top