berinhard / model_mommy

No longer maintained, please migrate to model_bakery
http://model-bakery.readthedocs.org/
Other
903 stars 141 forks source link

Save object instances when handling one to many relations #396

Closed anapaulagomes closed 5 years ago

anapaulagomes commented 5 years ago

Resolves #377 and a test for it (based on what was described).

This is a fork of @timthelion's solution (https://github.com/berinhard/model_mommy/pull/378). The tests were failing before because many to many relations doesn't have bulk as argument. See this comment from the docs:

For many-to-many relationships, the bulk keyword argument doesn’t exist.

timthelion commented 5 years ago

You even wrote tests :)

Thanks! :+1:

berinhard commented 5 years ago

@anapaulagomes and @amureki I think this one is good to go as well! The issue here was with the Dog model being created with prepare instead of make. The prepare method do not persist FK relationship, while make does. Because of that, the dog in the dog_set (man, what a phrasing...) couldn't be created because it was depending on the owner FK from being populated.

With f334db4f32d61557d5514890154f19c1ad0edbe3 the tests are now passing and I feel we're good to go with this PR as well :+1:

Thank you all and, again, sorry for the late response!