Closed ephess closed 11 years ago
This occurs just in the test context, but that is true.
This code is really danger because it changes the model globally. https://bitbucket.org/paulocheque/django-dynamic-fixture/commits/a943ed5f3efeee119a8aa47b26088bc3de0fa59b
Thanks a lot for reporting!
I am wondering another solution to avoid the auto_add and auto_now_add attributes to be changed globally.
ps: In this scenarios, you can try using debug mode to facilitate identify those things: https://github.com/paulocheque/django-dynamic-fixture/wiki/Documentation#wiki-debug_mode
I will post a comment here if I commit some solution.
Regards
Hi, I have fixed this issue, please check the commit: https://github.com/paulocheque/django-dynamic-fixture/commit/2b0e89630b117f8067f17d282704eb2cbcfe825f
Thanks a lot for reporting!
My tests started failing today due to a database consistency error on a datetime field when trying to instantiate a model. After a bit of debugging I noticed that the auto_now_add attribute on this field was changing from True to False at some point in the code.
I managed to track it down to get() call for the model, after a bit of digging I found the following function which seems to be the culprit:
https://github.com/paulocheque/django-dynamic-fixture/blob/master/django_dynamic_fixture/ddf.py#L265
Is there any reason for this? Seems like this would completely break most models that run through it with auto_now_add or auto_now set.
(Thanks for the great project by the way, code is so much cleaner (was using Model.objects.create() before :( )