Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Loading Django models from JSON #184
I've been using Factory Boy, and it's great. However I have an issue that I'm not sure how to deal with.
The first question is maybe easier -- how to represent Type. Type basically only has two db rows, and ideally I'd like to cycle between those two objects. If I make it a SubFactory, I'm not sure how to have the name and key fields linked -- they are not arbitrary/independent values. (One is a key for language translation, the other is a related English string.)
But that is wrong because it hits the database before the test_ database is set up, causing hard to trace errors.
The more general problem that comes with Location is that City is several levels deep, and here again, it doesn't make sense to make up random Cities that don't actually exist. I need to test with real ones.
In both cases, I really just want to load some data into the test database first, and /then/ start creating factory objects, using the loaded data to populate the foreign key fields of the factory objects.
Any help very much appreciated!