django-adminactions icon indicating copy to clipboard operation
django-adminactions copied to clipboard

Merge Selected action throws an exception

Open sdreher opened this issue 4 years ago • 0 comments

Summary The "Merge selected" action thrown an AttributeError exception in all instances. Django version is 2.24. Python version is 3.7.5.

To Reproduce To reproduce the issue in an application that integrates adminactions.

  • In the admin console, view the instance list for a model.
  • Choose two instances.
  • Select the "Merge selected" action.
  • Click Go.
  • The user is navigated to the "Merge" screen.
  • Click Preview.

Expected The user will be navigated to a final screen in preparation for a merge.

Actual An exception is thrown.

AttributeError: module 'adminactions.compat' has no attribute 'get_all_related_objects'
  File "django/core/handlers/exception.py", line 34, in inner
    response = get_response(request)
  File "django/core/handlers/base.py", line 115, in _get_response
    response = self.process_exception_by_middleware(e, request)
  File "django/core/handlers/base.py", line 113, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "django/contrib/admin/options.py", line 606, in wrapper
    return self.admin_site.admin_view(view)(*args, **kwargs)
  File "django/utils/decorators.py", line 142, in _wrapped_view
    response = view_func(request, *args, **kwargs)
  File "django/views/decorators/cache.py", line 44, in _wrapped_view_func
    response = view_func(request, *args, **kwargs)
  File "django/contrib/admin/sites.py", line 223, in inner
    return view(request, *args, **kwargs)
  File "django/utils/decorators.py", line 45, in _wrapper
    return bound_method(*args, **kwargs)
  File "django/utils/decorators.py", line 142, in _wrapped_view
    response = view_func(request, *args, **kwargs)
  File "django/contrib/admin/options.py", line 1727, in changelist_view
    response = self.response_action(request, queryset=cl.get_queryset(request))
  File "django/contrib/admin/options.py", line 1397, in response_action
    response = func(self, request, queryset)
  File "adminactions/merge.py", line 149, in merge
    is_valid, form, merge_kwargs = validate(request, master, other)
  File "adminactions/merge.py", line 124, in validate
    api.merge(master, other, commit=True, **merge_kwargs)
  File "adminactions/api.py", line 59, in merge
    for rel in compat.get_all_related_objects(master)]

Possible cause Tracing this down, it looks like compat.py was updated on August 12th, which removed several methods. https://github.com/saxix/django-adminactions/commit/7c0638560aa226ef5b0f60fad45a99092ddc4e9c#diff-47dc9d61aa29aa6a0f6b3d54cd401c4c96796e0d9c44392ba748789da4be1aa5L29

There are still two references to the removed compatibility methods:

  • https://github.com/saxix/django-adminactions/blob/develop/src/adminactions/api.py#L59
  • https://github.com/saxix/django-adminactions/blob/develop/src/adminactions/api.py#L266

sdreher avatar Aug 24 '21 16:08 sdreher