Opened 2 years ago
Closed 2 years ago
#34114 closed Bug (duplicate)
loaddata doesn't honor auto_now_add=True when these values are missing.
Reported by: | Roger | Owned by: | nobody |
---|---|---|---|
Component: | Core (Management commands) | Version: | 4.1 |
Severity: | Normal | Keywords: | fixtures loaddata yaml |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
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
Change History (1)
comment:1 by , 2 years ago
Component: | Uncategorized → Core (Management commands) |
---|---|
Resolution: | → duplicate |
Status: | new → closed |
Summary: | loading fixtures (loaddata) doesn't seem to honour auto_now_add=True when these values are missing → loaddata doesn't honor auto_now_add=True when these values are missing. |
Note:
See TracTickets
for help on using tickets.
Duplicate of #28951.