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

How to fill many to many relations? #117

Open
sergeypoprovka opened this issue Sep 8, 2023 · 1 comment
Open

How to fill many to many relations? #117

sergeypoprovka opened this issue Sep 8, 2023 · 1 comment

Comments

@sergeypoprovka
Copy link

Hey!

Inside the User model I have Skills relation which is many-to-many filed. It can't be null. So when I'm trying to use Django-seed w/o extra params - it's giving me the error that "The field can't be null". Which is logical.
But when I'm trying to pass list of Skill objects there - it's giving me

**TypeError: Direct assignment to the forward side of a many-to-many set is prohibited.**

So the question is - if it's possible at all to seed many-to-many model? And if yes - how to do that?

@ethagnawl
Copy link

ethagnawl commented Sep 30, 2024

This is interesting, @sergeypoprovka. I find myself in the opposite situation where seeder is creating M2M relationships when I don't want them and I see that error when trying to specify an empty queryset or none literally in the override kwarg.

Have you tried creating seed Skills before seed Users?

In my case, I'm temporarily using a fork which removes the auto-population behavior altogether but it'd be nice to solve this cleanly in both our cases upstream.

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

2 participants