Closed berinhard closed 11 years ago
Looks good. It would be good to work with prepare_one, since ForeignKeys associations are persisted. Also, it can work with recipes, in order to keep a consistent API.
I've looked at the recipe API but I couldn't add this feature to that API.
This is because the recipe lays on creating a model instance given specific fields. At the ends, the recipes are quita a shortcut or alias to a Model.objects.create
call. So, as it lays on fields explicitly determined I think this feature just doesn't make sense with the recipes API.
PS. I've updated the pull request updating the docs
I'm thinking if we could use the Mommy's _make_one method in order to provide such thing.
Supose that we have two models:
Now, imagine if we have a single test method that needs an instance of Foo which has a reference to a Bar's instance with a specif name value such as "Bob". In the current state of mode_mommy, the way to achieve this problem is just like the code bellow:
I'm imagining an API similar to Django Queryset Field Lookup. Something lke the following code:
What do you think? I' want to work on this feature by now...