# Using a multi-table inheritance model as a through table

**URL:** https://forum.djangoproject.com/t/using-a-multi-table-inheritance-model-as-a-through-table/8770
**Category:** Using Django
**Created:** [July 14, 2021, 2:09am UTC](https://forum.djangoproject.com/t/using-a-multi-table-inheritance-model-as-a-through-table/8770 "2021-07-14T02:09:05Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![dob9601](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/dob9601/32/5144_2.png) [@dob9601](https://forum.djangoproject.com/u/dob9601)
#### Post date: [July 14, 2021, 2:09am UTC](https://forum.djangoproject.com/t/using-a-multi-table-inheritance-model-as-a-through-table/8770/1 "2021-07-14T02:09:05Z")

</div>

I’m trying to use a multi-table inheritance model as a through table, as shown below:

```auto
class Base(models.Model):
  ...

class Through(Base):
  ...

class RelatedModel(models.Model):
  ...

class Model(models.Model):
  field = models.ManyToManyField(RelatedModel, through='Base')

instance = Model.objects.get(pk=1)
related = RelatedModel.objects.get(pk=1)
instance.add(related) # ValueError: Can't bulk create a multi-table inherited model

```

However, I keep running into an error when adding a model to the ManyToMany relationship, as to how multi-table inheritance models cannot be bulk created. Is there any way around this? ManyToManyField.add doesn’t take a `bulk` argument so it doesn’t seem to be possible to disable bulk creation there.

Does anyone know of a workaround for this without getting rid of the inheritance?

---

<div class="post-metadata">

### Author: ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)
#### Post date: [July 14, 2021, 12:53pm UTC](https://forum.djangoproject.com/t/using-a-multi-table-inheritance-model-as-a-through-table/8770/2 "2021-07-14T12:53:17Z")

</div>

Actually, `add` _is_ a bulk operation. It uses the `*args` notation to accept all positional parameters as a list. (`*objs` in this specific case) See the [.add method docs](https://docs.djangoproject.com/en/3.2/ref/models/relations/#django.db.models.fields.related.RelatedManager.add).

In other words, you can do something like `instance.add(r1, r2, r3, r4)`, inserting all values at once. (See the various examples at [Many-to-many relationships | Django documentation | Django](https://docs.djangoproject.com/en/3.2/topics/db/examples/many_to_many/))

Since you’re using a `through` table here, you could just create the table instances directly - assuming:

```auto
class Base(...):
    model = ForeignKey(Model, ...)
    related_model = ForeignKey(RelatedModel, ...)
    ...

```

Then, you can establish your relationship as:

```auto
instance = Model.objects.get(pk=1)
related = RelatedModel.objects.get(pk=1)
base = Base(model=instance, related_model=related, ...)
base.save()

```
