Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow string values for foriegn_key from other modules #52

Closed
knyghty opened this issue Dec 19, 2019 · 0 comments · Fixed by #120
Closed

Allow string values for foriegn_key from other modules #52

knyghty opened this issue Dec 19, 2019 · 0 comments · Fixed by #120

Comments

@knyghty
Copy link
Contributor

knyghty commented Dec 19, 2019

It would be nice if we could treat foreign keys like we would a recipe in baker.make(). Right now it seems like whatever foreign key you use has to be imported into that baker_recipes.py file.

Expected behavior

It would be nice to be able to do something like:

order = Recipe(account=foreign_key('accounts.account'))

It would be even nicer if this would handle things gracefully, if you had for example one recipe that creates an order tied to an account, and a recipe that creates an account with several orders, both in different baker_recipes.py files.

Actual behavior

I get an error in the form of:

AttributeError: module 'order.baker_recipes' has no attribute 'account.account'

Reproduction Steps

Create two baker_recipes.py files in different django apps/whatever and try to use them together without importing recipes from the other.

Versions

Python: 3.7
Django: 2.2
Model Bakery: 1.0.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant