paulocheque / django-dynamic-fixture

A complete library to create dynamic model instances for testing purposes.
http://django-dynamic-fixture.readthedocs.io/
Other
390 stars 67 forks source link

null=True, blank=True fields are given values unless default=None #7

Closed tobych closed 12 years ago

tobych commented 12 years ago

I have a model with this field:

reset_timestamp = models.DateTimeField(null=True, blank=True)

To my surprise, DDF sets this field with a date when instantiating the model. I was expecting it to leave it blank, because it can be, and that's what Django would do, even though it doesn't explicitly set default=None. I had to do that to avoid this happening:

reset_timestamp = models.DateTimeField(null=True, blank=True, default=None)

Is this supposed to be happening? Should I be including explicit defaults in all my nullable fields?

paulocheque commented 12 years ago

Hi. Look for "fill_nullable_fields" in https://github.com/paulocheque/django-dynamic-fixture/wiki/Documentation

You can change the default behavior of DDF globally or just for one scenario.

DDF_FILL_NULLABLE_FIELDS = True instance = G(MyModel, fill_nullable_fields=False)

tobych commented 12 years ago

Thanks for the explanation. I'm surprised this is the default, but it makes sense now. Ta!