Closed tkhyn closed 6 years ago
Original comment by Thomas Khyn (Bitbucket: tkhyn, GitHub: tkhyn).
Hi, GM2MField is like django's built-in ManyToManyField. You cannot initialise it when you create the instance. And if you could, you would need to pass a list, not a single instance (https://github.com/chronoscio/backend/blob/wh-Entity/project/api/tests.py#L69)
The way to provide initial values to a GM2MField is to create the model instance first, then populate the field.
See https://stackoverflow.com/a/6996358/1445719 or https://docs.djangoproject.com/en/2.1/topics/db/examples/many_to_many/
Original report by Ata Ali Kilicli (Bitbucket: ataalik, GitHub: ataalik).
Hello, I wanted to use gm2m for creating manytomany generic relations because one of our models called entity is abstract and will be inherited by many classes. I tried a very basic setup where I create a GM2MField() on a third class and try to instance it with a PoliticalEntity inheriting from the abstract entity. That's when I get this error.
I'm including a basic setup of mentioned models. You can find the whole code here