Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Mockups for unique foreign keys #7

Open
sirex opened this Issue · 2 comments

3 participants

@sirex

Now, default behavior when creating mockups for foreign key fields is to reuse an existing object for that field. But if foreign keys are unique this behavior always ends up with error:

CreateInstanceError: Cannot solve constraints for "%s", tried 1000 times. Please check value generators or model constraints. At least the following fields are involved: myfield

To solve this I need to explicitly specify, that new object for that field should be created:

instance = mockups.create_one(Account, generate_fk=['myfield'])

Maybe it would be better to automatically create new object for unique fields? Or at least check if an existing object is not already assigned, if it is, then create new one?

@sorl
Owner

Yes, that sounds reasonable i think.

@airtonix

It seems this is still an issue. Did you guys get around to solving this?

I notice that the OneToOneFieldGenerator is still just a "synonym" class to ForeignKeyFieldGenerator.

Don't you think it should contain some logic to follow the outcomes of the discussion in this thread?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.