Closed wesleykendall closed 4 years ago
+1
Change the default value I dont think it is a good idea because it may break every test for every people using the tool after upgrading the library.
I believe it is a good idea to have a method like this, but we have to find a good name for it. Why do you think in M?
In the mean time, I believe you can create a wrapper like that:
def something(model, shelve=False, n=1, persist_dependencies=False, **kwargs):
N(model, shelve=shelve, n=n, persist_dependencies=persist_dependencies, **kwargs)
N = something
@paulocheque what do you think about this?
# global_settings.py
DDF_N_PERSIST_DEPENDENCIES = get_boolean_config('DDF_N_PERSIST_DEPENDENCIES', default=True)
# django_dynamic_fixture/__init__.py
def new(model, shelve=False, n=1, persist_dependencies=DDF_N_PERSIST_DEPENDENCIES, **kwargs):
Very cool! Could you make a PR?
@paulocheque I'll do a PR/tests/docs if you are fine with that implementation. This will help us tremendously!
Amazing! I will merge and generate a release for it! best!
Well, I changed the default value for the next DDF version 3, which will have some big changes and incompatibilities with older versions.
https://github.com/paulocheque/django-dynamic-fixture/pull/108
Thanks @wesleykendall @micahhausler
@paulocheque thanks so much for this change! Loving version 3!
According to https://github.com/paulocheque/django-dynamic-fixture/blob/master/django_dynamic_fixture/__init__.py#L71 and the docs, persist_dependencies is True by default for the N function. Almost 100% of time in our code we have to type persist_dependencies=False, and it's cumbersome to have to manually review code and ensure people aren't accidentally hitting the DB when they instantiate in-memory models.
My question - can this default behavior be changed? If it's too backwards breaking, can I add an M function that is N with persist_dependencies=False?