我测试了以下代码:https://code.djangoproject.com/ticket/11760# 但这不起作用
class ClassA(models.Model):
pass
class AbstractClass(models.Model):
name = models.ManyToManyField(ClassA, related_name = '%(class)s_name', through = 'ClassA_%(class)s')
class Meta:
abstract = True
class MyClass(AbstractClass):
pass
class ClassA_MyClass(models.Model):
class_a=models.ForeignKey(ClassA, on_delete=models.CASCADE)
my_class=models.ForeignKey(MyClass, on_delete=models.CASCADE)
我遇到此错误:
(fields.E331) Field specifies a many-to-many relation through model 'ClassA_%(class)s', which has not been installed.