model_utils _clone() got an unexpected keyword argument 'subclasses'

2023-02-18 14:49:53 浏览数 (1)

发生环境

从 Django 1.11 迁移到 Django 2.2

错误日志

代码语言:javascript复制
django.request: 2020-05-22 16:12:18,196 E:py_virtualenvjoyoolibsite-packagesdjangoutilslog.py [line:228] ERROR Internal Server Error: /friendUrlAdd/
Traceback (most recent call last):
  File "E:py_virtualenvjoyoolibsite-packagesdjangocorehandlersexception.py", line 34, in inner
    response = get_response(request)
  File "E:py_virtualenvjoyoolibsite-packagesdjangocorehandlersbase.py", line 115, in _get_response
    response = self.process_exception_by_middleware(e, request)
  File "E:py_virtualenvjoyoolibsite-packagesdjangocorehandlersbase.py", line 113, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "E:yinzhuoqundjangosjoyooblogviews.py", line 1151, in friend_url_add
    user = User.objects.get(pk=1)
  File "E:py_virtualenvjoyoolibsite-packagesdjangodbmodelsmanager.py", line 82, in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
  File "E:py_virtualenvjoyoolibsite-packagesdjangodbmodelsquery.py", line 399, in get
    clone = self.filter(*args, **kwargs)
  File "E:py_virtualenvjoyoolibsite-packagesdjangodbmodelsquery.py", line 892, in filter
    return self._filter_or_exclude(False, *args, **kwargs)
  File "E:py_virtualenvjoyoolibsite-packagesdjangodbmodelsquery.py", line 906, in _filter_or_exclude
    clone = self._chain()
  File "E:py_virtualenvjoyoolibsite-packagesdjangodbmodelsquery.py", line 1219, in _chain
    obj = self._clone()
  File "E:py_virtualenvjoyoolibsite-packagesmodel_utilsmanagers.py", line 100, in _clone
    return super(InheritanceQuerySetMixin, self)._clone(**kwargs)
TypeError: _clone() got an unexpected keyword argument 'subclasses'

解决办法

升级 django-model-utils

代码语言:javascript复制
(joyoo) E:yinzhuoqundjangosjoyoo>pip install django-model-utils --upgrade
Collecting django-model-utils
  Downloading django_model_utils-4.0.0-py2.py3-none-any.whl (29 kB)
Requirement already satisfied, skipping upgrade: Django>=2.0.1 in e:py_virtualenvjoyoolibsite-packages (from django-model-utils) (2.2.12)
Requirement already satisfied, skipping upgrade: pytz in e:py_virtualenvjoyoolibsite-packages (from Django>=2.0.1->django-model-utils) (2017.2)
Requirement already satisfied, skipping upgrade: sqlparse in e:py_virtualenvjoyoolibsite-packages (from Django>=2.0.1->django-model-utils) (0.3.0)
Installing collected packages: django-model-utils
  Attempting uninstall: django-model-utils
    Found existing installation: django-model-utils 3.0.0
    Uninstalling django-model-utils-3.0.0:
      Successfully uninstalled django-model-utils-3.0.0
Successfully installed django-model-utils-4.0.0

0 人点赞