TypeError:_add_items()获得了意外的关键字参数'through_defaults'

时间:2019-05-23 02:07:55

标签: django photologue

我刚刚将Photologue应用程序添加到了一个新的Django项目中。除了...以外,该安装似乎已正常运行。 ...当我尝试添加初始图库时,出现以下错误 TypeError: _add_items() got an unexpected keyword argument 'through_defaults

根据照片阅读文档的说明,在MacOS 10.14上使用pip3安装的所有软件包。

Internal Server Error: /admin/photologue/gallery/add/
Traceback (most recent call last):
  File "/Users/myuser/Envs/env1/lib/python3.7/site-packages/django/core/handlers/exception.py", line 34, in inner
    response = get_response(request)
  File "/Users/myuser/Envs/env1/lib/python3.7/site-packages/django/core/handlers/base.py", line 115, in _get_response
    response = self.process_exception_by_middleware(e, request)
  File "/Users/myuser/Envs/env1/lib/python3.7/site-packages/django/core/handlers/base.py", line 113, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/Users/myuser/Envs/env1/lib/python3.7/site-packages/django/contrib/admin/options.py", line 606, in wrapper
    return self.admin_site.admin_view(view)(*args, **kwargs)
  File "/Users/myuser/Envs/env1/lib/python3.7/site-packages/django/utils/decorators.py", line 142, in _wrapped_view
    response = view_func(request, *args, **kwargs)
  File "/Users/myuser/Envs/env1/lib/python3.7/site-packages/django/views/decorators/cache.py", line 44, in _wrapped_view_func
    response = view_func(request, *args, **kwargs)
  File "/Users/myuser/Envs/env1/lib/python3.7/site-packages/django/contrib/admin/sites.py", line 223, in inner
    return view(request, *args, **kwargs)
  File "/Users/myuser/Envs/env1/lib/python3.7/site-packages/django/contrib/admin/options.py", line 1634, in add_view
    return self.changeform_view(request, None, form_url, extra_context)
  File "/Users/myuser/Envs/env1/lib/python3.7/site-packages/django/utils/decorators.py", line 45, in _wrapper
    return bound_method(*args, **kwargs)
  File "/Users/myuser/Envs/env1/lib/python3.7/site-packages/django/utils/decorators.py", line 142, in _wrapped_view
    response = view_func(request, *args, **kwargs)
  File "/Users/myuser/Envs/env1/lib/python3.7/site-packages/django/contrib/admin/options.py", line 1522, in changeform_view
    return self._changeform_view(request, object_id, form_url, extra_context)
  File "/Users/myuser/Envs/env1/lib/python3.7/site-packages/django/contrib/admin/options.py", line 1562, in _changeform_view
    self.save_related(request, form, formsets, not add)
  File "/Users/myuser/Envs/env1/lib/python3.7/site-packages/photologue/admin.py", line 57, in save_related
    super(GalleryAdmin, self).save_related(request, form, *args, **kwargs)
  File "/Users/myuser/Envs/env1/lib/python3.7/site-packages/django/contrib/admin/options.py", line 1114, in save_related
    form.save_m2m()
  File "/Users/myuser/Envs/env1/lib/python3.7/site-packages/django/forms/models.py", line 441, in _save_m2m
    f.save_form_data(self.instance, cleaned_data[f.name])
  File "/Users/myuser/Envs/env1/lib/python3.7/site-packages/django/db/models/fields/related.py", line 1621, in save_form_data
    getattr(instance, self.attname).set(data)
  File "/Users/myuser/Envs/env1/lib/python3.7/site-packages/sortedm2m/fields.py", line 92, in set
    super(SortedRelatedManager, self).set(objs, **kwargs)
  File "/Users/myuser/Envs/env1/lib/python3.7/site-packages/django/db/models/fields/related_descriptors.py", line 981, in set
    self.add(*objs, through_defaults=through_defaults)
  File "/Users/myuser/Envs/env1/lib/python3.7/site-packages/django/db/models/fields/related_descriptors.py", line 938, in add
    through_defaults=through_defaults,
TypeError: _add_items() got an unexpected keyword argument 'through_defaults'
[23/May/2019 11:56:11] "POST /admin/photologue/gallery/add/ HTTP/1.1" 500 136703

1 个答案:

答案 0 :(得分:0)

自Django 2.2以来似乎是一个错误。降级到2.1.9,就可以了。

如果没有,您可以在https://github.com/gregmuellegger/django-sortedm2m/issues/130

中找到更多信息。