Friday, July 2, 2021

Re: Admin TypeError - Cannot call delete() after .distinct()


https://code.djangoproject.com/ticket/32682 might be the root cause, which was fixed end of April and part of the 3.2.1 release, doesn't seem like its been backported to 3.1
On Friday, July 2, 2021 at 2:03:28 AM UTC-4 Mike Dewhirst wrote:
Trying to delete a record in the Admin list view by checking the
checkbox and selecting the delete action and clicking [Go] the following
500 error happened.

It seems to be all within the Admin so I'm not sure how to proceed from
here.

Thanks for any hints

Mike

Traceback (most recent call last):
  File
"D:\Users\mike\envs\xxai\lib\site-packages\django\core\handlers\exception.py",
line 47, in inner
    response = get_response(request)
  File
"D:\Users\mike\envs\xxai\lib\site-packages\django\core\handlers\base.py",
line 181, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File
"D:\Users\mike\envs\xxai\lib\site-packages\django\contrib\admin\options.py",
line 616, in wrapper
    return self.admin_site.admin_view(view)(*args, **kwargs)
  File
"D:\Users\mike\envs\xxai\lib\site-packages\django\utils\decorators.py",
line 130, in _wrapped_view
    response = view_func(request, *args, **kwargs)
  File
"D:\Users\mike\envs\xxai\lib\site-packages\django\views\decorators\cache.py",
line 44, in _wrapped_view_func
    response = view_func(request, *args, **kwargs)
  File
"D:\Users\mike\envs\xxai\lib\site-packages\django\contrib\admin\sites.py",
line 232, in inner
    return view(request, *args, **kwargs)
  File
"D:\Users\mike\envs\xxai\lib\site-packages\django\utils\decorators.py",
line 43, in _wrapper
    return bound_method(*args, **kwargs)
  File
"D:\Users\mike\envs\xxai\lib\site-packages\django\utils\decorators.py",
line 130, in _wrapped_view
    response = view_func(request, *args, **kwargs)
  File
"D:\Users\mike\envs\xxai\lib\site-packages\django\contrib\admin\options.py",
line 1739, in changelist_view
    response = self.response_action(request,
queryset=cl.get_queryset(request))
  File
"D:\Users\mike\envs\xxai\lib\site-packages\django\contrib\admin\options.py",
line 1408, in response_action
    response = func(self, request, queryset)
  File
"D:\Users\mike\envs\xxai\lib\site-packages\django\contrib\admin\actions.py",
line 45, in delete_selected
    modeladmin.delete_queryset(request, queryset)
  File
"D:\Users\mike\envs\xxai\lib\site-packages\django\contrib\admin\options.py",
line 1109, in delete_queryset
    queryset.delete()
  File
"D:\Users\mike\envs\xxai\lib\site-packages\django\db\models\query.py",
line 728, in delete
    raise TypeError('Cannot call delete() after .distinct().')

Exception Type: TypeError at /admin/chemical/chemical/
Exception Value: Cannot call delete() after .distinct().

--
Signed email is an absolute defence against phishing. This email has
been signed with my private key. If you import my public key you can
automatically decrypt my signature and be sure it came from me. Just
ask and I'll send it to you. Your email software can handle signing.


--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/086bef60-4422-4021-949b-84e19e9768b2n%40googlegroups.com.

No comments:

Post a Comment