Closed mrmachine closed 9 years ago
I am not sure if this is what you are looking for, but there is global setting called DDF_FILL_NULLABLE_FIELDS (http://django-dynamic-fixture.readthedocs.org/en/latest/ddf.html#global-settings) and it should control this behaviour. I remember that last time I tried to use it it did not work as I expected, but maybe it does now. Please let me know if it works.
Jano
Exactly. Use DDF_FILL_NULLABLE_FIELDS
or fill_nullable_fields=False
.
When DDF_FILL_NULLABLE_FIELDS = False
, DDF appears to explicitly set unspecified fields to null
even when they have a default configured in the model.
Shouldn't it just not set any value at all for those fields, so Django can use its configured default (which is None
if there is no default)?
Or perhaps a DDF_FILL_DEFAULT_FIELDS
setting (True
by default for backwards compatibility) that allows the model field default to be used for fields that are not explicitly provided by the user, regardless of the DDF_FILL_NULLABLE_FIELDS
setting.
A DDF_FILL_UNIQUE_FIELDS
setting might also be useful.
I have a bunch of models with
ForeignKey
fields that can be null and which have no default value specified. DDF always tries to auto fill these fields when I useG()
. I end up having to constantly doG(foo=None, ...)
to stop it, or put a redundantForeignKey('Foo', default=None, null=True)
in my model.DDF should only auto fill fields that are required to pass model validation?