访问 parent-class 元素时的 InheritanceManager 错误 (Django 2.0)

InheritanceManager bug when access parent-class elements (Django 2.0)

我目前正在尝试在 Django 2.0 (Python 3.6.3) 中使用一个父 class 程序和一些子程序 classes 代码段和软件.我看到 model_utils 模块包含一些处理多态性的工具,并尝试复制教程 (http://django-model-utils.readthedocs.io/en/latest/managers.html),这是它在我的案例中提供的内容:

models.py

from django.db import models
from model_utils.managers import InheritanceManager

class Program(models.Model):
    name = models.CharField(max_length=100)

    objects = InheritanceManager()

class Snippet(Program):
    code = models.TextField()

class Software(Program):
    repoLink = models.URLField()

Django shell

>>> from coding.models import Program
>>> programs = Program.objects.select_subclasses()
>>> programs
Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "...\py3django\lib\site-packages\django\db\models\query.py", line 248, in __repr__
    data = list(self[:REPR_OUTPUT_SIZE + 1])
  File "...\py3django\lib\site-packages\django\db\models\query.py", line 292, in __getitem__
    qs = self._chain()
  File "...\py3django\lib\site-packages\django\db\models\query.py", line 1156, in _chain
    obj = self._clone()
  File "...\py3django\lib\site-packages\model_utils\managers.py", line 100, in _clone
    return super(InheritanceQuerySetMixin, self)._clone(**kwargs)
TypeError: _clone() got an unexpected keyword argument 'subclasses'

我不明白这个错误以及如何修复它,甚至不知道这是我的设计失败还是 InheritanceManager 使用不当。那么此错误消息的来源是什么?

根据the docs,django-model-utils 仅支持 Django 1.8 到 1.10。