[Django] #34114: loading fixtures (loaddata) doesn't seem to honour auto_now_add=True when these values are missing

49 views
Skip to first unread message

Django

unread,
Oct 24, 2022, 5:14:29 AM10/24/22
to django-...@googlegroups.com
#34114: loading fixtures (loaddata) doesn't seem to honour auto_now_add=True when
these values are missing
-------------------------------------+-------------------------------------
Reporter: rbosch | Owner: nobody
Type: Bug | Status: new
Component: | Version: 4.1
Uncategorized | Keywords: fixtures loaddata
Severity: Normal | yaml
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
In my model I have a model with a DateTime field (models.DateTimeField)
defined as follows:

{{{
class MyModal(models.Model):
key = models.CharField(max_length=20, blank=False, null=False)
created_at = models.DateTimeField(blank=False, null=False,
auto_now_add=True)
}}}

When loading the data via the fixtures and ''omitting'' the created_at
field, I would assume created_at will be set to ''now''

I'm getting a error:
{{{
Could not load app.MyModal(pk=None): (1048, "Column 'created_at' cannot be
null")
}}}

YAML:

{{{
- model: app.mymodal
fields:
key: some text value
}}}

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

Reply all
Reply to author
Forward
0 new messages