[Solved]-Django. Invalid keyword argument for this function. ManyToMany

23👍

You need to save/create the object before you can add ManyToMany relationships:

up = UserPassage.objects.create(passage=passage)
up.people.add(user_profil)

ManyToMany relationships aren’t saved as columns in your table. Read the first reply here for good explanation:

Django ManyToMany field is not created in model

@DanielRoseman: Because a ManyToMany isn’t a field, at least not one that exists as a database column. It’s a relationship with a linking table. You’ll find that a table named myapp_teacher_subjects has been created, with foreign keys to both teacher and subjects.

Leave a comment