我的自定义管理器代码如下:
class CustomManager(models.Manager):
def create(self, **kwargs):
obj, created = Group.objects.get_or_create(name='group1')
kwargs.update({'groups': obj})
return super(CustomManager, self).create(**kwargs)
这会创建TypeError: Direct assignment to the forward side of a many-to-many set is prohibited. Use groups.set() instead..