0

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

根据 photologue read-the-doc,在 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
4

1 回答 1

0

自 Django 2.2 以来似乎是一个错误。降级到 2.1.9,你会没事的。

如果没有,您可以在以下位置找到更多信息:https ://github.com/gregmuellegger/django-sortedm2m/issues/130

于 2019-06-06T16:51:07.790 回答