djangocms-blog icon indicating copy to clipboard operation
djangocms-blog copied to clipboard

When removing a blog post i get cannot call delete() after .distinct().

Open svandeneertwegh opened this issue 3 years ago • 7 comments

I cannot remove a blog post. I get "Cannot call delete() after .distinct()."

Steps to reproduce

djangocms_blog==1.2.3 django==3.2.5

Apparently this repo is not ready for django 3.2.5.. When i switch back to django==1.2.9 it does work..

svandeneertwegh avatar Jul 18 '21 12:07 svandeneertwegh

Seeing the same here

petrklus avatar Feb 16 '22 12:02 petrklus

# admin deletion fix
from djangocms_blog.admin import PostAdmin
def new_get_queryset_admin(self, request):
    qs = super(PostAdmin, self).get_queryset(request)
    sites = self.get_restricted_sites(request)
    if sites.exists():
        pks = list(sites.all().values_list("pk", flat=True))
        qs = qs.filter(sites__in=pks)
    return qs #.distinct() DJ32 fix
PostAdmin.get_queryset = new_get_queryset_admin

@svandeneertwegh if still relevant, I am using the above monkey-patch to get deletion working again in the list view. Not seeing any other side-effects with my simple setup.

petrklus avatar Feb 16 '22 12:02 petrklus

Perhaps @yakky will know more - is the distinct actually required? (present here: https://github.com/nephila/djangocms-blog/blob/develop/djangocms_blog/admin.py#L439)

I do not seem to be observing any ill-effects after our monkey-patch.

petrklus avatar Feb 18 '22 10:02 petrklus

For me the same issue was fixed via setting

Django = ">=3.2,<3.3"

in pyproject.toml, so it selected itself Django 3.2.13.

szabozoltan69 avatar May 23 '22 12:05 szabozoltan69

The bug is still present for me with djangocms-blog==1.2.3 and Django==3.2.13.

adrien-delhorme avatar May 25 '22 13:05 adrien-delhorme

any solution? django bug?

JohnYan2017 avatar Jul 04 '22 13:07 JohnYan2017

any solution? django bug?

I would not call it a bug, it is more of a behaviour change that we need to adapt to.

petrklus avatar Jul 04 '22 15:07 petrklus

Thanks for reporting this, it's fixed in #735

yakky avatar May 25 '23 13:05 yakky