From 25adb8378ea09274d46885e055e74dd386d4657a Mon Sep 17 00:00:00 2001 From: collerek Date: Fri, 6 Aug 2021 11:59:16 +0200 Subject: [PATCH] fix for #295 --- ormar/fields/many_to_many.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/ormar/fields/many_to_many.py b/ormar/fields/many_to_many.py index b68821f..2f4cc3e 100644 --- a/ormar/fields/many_to_many.py +++ b/ormar/fields/many_to_many.py @@ -275,5 +275,9 @@ class ManyToManyField(ForeignKeyField, ormar.QuerySetProtocol, ormar.RelationPro "metadata": self.owner.Meta.metadata, } new_meta = type("Meta", (), new_meta_namespace) - through_model = type(class_name, (ormar.Model,), {"Meta": new_meta}) + through_model = type( + class_name, + (ormar.Model,), + {"Meta": new_meta, "id": ormar.Integer(name="id", primary_key=True)}, + ) self.through = cast(Type["Model"], through_model)