Hi!
I need help on how to save the same (reference to an) object into a ManyToManyField. For example I have models like this:
class Material(models.Model):
name = models.CharField(max_length=50)
class Compound(models.Model):
materials = models.ManyToManyField(Material)
In this example, the Compound
can be made of one or many different Material
s, and it also could be made from the same Material
twice (same id
in Material
model).
If I try to save through a ModelForm
, the second Material
is discarded because it has the same id
as the first Material
.
What is the best approach for this?
Thank you!