#28951: loaddata from fixture doesn't work with null=False auto_now_add fields
-------------------------------------+-------------------------------------
Reporter: infintesimal | Owner: nobody
Type: Uncategorized | Status: new
Component: Uncategorized | Version: 2.0
Severity: Normal | Resolution:
Keywords: loaddata | Triage Stage:
auto_now_add fixtures | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Ramiro Morales):
IMHO, the most predictable choice would be to actually provide the
`Foo.created` values in your fixture file.
I don't think it would be correct nor practical to make loaddata smart
about this because it could open the door to more choices: e.g. What value
should it set when faced with fixture files like:
* say, 1000 Foo's. Should it set one unique timestamp for every Foo?
Should it set 1000 different values set apart for a few miliseconds?
* What if Foo has more than one `DateTimeField` with `auto_now_add=True`?
* What if it includes instances of more than one model with a
`DateTimeField` field with `auto_now_add=True`?
One choice Django makes here would cater for some use cases bot not for
others. Then it's possible we would receive requests to make the smart
behavior customizable from the command line, ...
Another option is to use tools like factory_boy
--
Ticket URL: <https://code.djangoproject.com/ticket/28951#comment:1>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/070.6a43e79cd63212a78210f4540274cb84%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.