I get the error:
TypeError: 'person' is an invalid keyword argument for this function
My model is:
class Investment(models.Model):
company = models.ManyToManyField("Company", related_name ="Investments_company")
financial_org = models.ManyToManyField("Financial_org", related_name ="Investments_financial_org")
person = models.ManyToManyField("Person", related_name ="Investments_person")
My test (that gives the error):
investment1 = Investment(company = [], financial_org = financial1, person = [])
Instanciate your model without many to many, investment1 = Investment()
Save your model, investment1.save()
Add many to many, there are several ways to do it like investment1.person.add(person_model)
or investment1.person.create(name='foo')
You may not use a ManyToMany relation until a model is saved, this is because a row in a ManyToMany relation table needs the pk of the models at the two sides of the relations.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With