I have a model similar to this one:
class A(models.Model):
name = models.CharField(primary_key=True)
class B(models.Model):
(morefields)
target = models.ManyToManyField(A,through='C')
class C(models.Model):
a_key = models.ForeignKey(A)
b_key = models.ForeignKey(B)
(extra fields)
I am creating a form to edit an item of B using a modelForm. However, I get “Cannot set values on a ManyToManyField which specifies an intermediary model” error. If I exclude the target field it works fine.
Could you suggest any way to workaround this?
You can use inlines. The problem is that Django can’t create the relation for you because there’s additional fields that must be set on the join table (your “through” model). Try the following: