Hi, I was working on a many-to-many model with extra fields and i saw the documentation for extra fields in many to many relations
on their exemple, to create a membership they use
m2 = Membership.objects.create(person=paul, group=beatles,date_joined=date(1960, 8, 1), invite_reason= "Wanted to form a band.")
but that means that they already have the "person" and "group" instances. Normally working in websites we have the id's of the objects... so to create a membership i'd have to do:
person = Person.objects.get(pk=idPerson)
group = Group.objects.get(pk=idgroup)
Now, correct me if i'm wrong but aren't we consulting pointlessly the database two times before the insert? because, all we need in the Membership is the foreign key id's and not the whole object... maybe there's another way to insert in a many-to-many relation using only the id's