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

.create() method fails when model has foreign keys #142

Closed
luisiacc opened this issue Jun 4, 2021 · 2 comments
Closed

.create() method fails when model has foreign keys #142

luisiacc opened this issue Jun 4, 2021 · 2 comments

Comments

@luisiacc
Copy link

luisiacc commented Jun 4, 2021

When trying to create a mock model that has some PKs, it fails with:

ValueError: Cannot assign "mock-pizza-1": "MyModel.pizzas" must be a "Pizza" instance

Could have something to do with this. Is there a good way to do this ?

An implementation option would be to remove all relations from the save method, and putting them somewhere else, so when you try to access them, you access them from that place. This is a philosophy that is used in some DRF nested serializers.

@MartinGotelli
Copy link
Contributor

@stefan6419846 do you think this gets solved whit #174?

@stefan6419846
Copy link
Collaborator

stefan6419846 commented Apr 19, 2024

@MartinGotelli At least the message looks like this. I am going to close this issue as solved. If this is indeed a different issue, re-opening the issue once there are more reproduction details should be no big deal.

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

No branches or pull requests

3 participants