Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
svandeneertwegh opened this issue Jul 18, 2021 · 8 comments · Fixed by #735
Closed

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

svandeneertwegh opened this issue Jul 18, 2021 · 8 comments · Fixed by #735

Comments

@svandeneertwegh
Copy link

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..

@petrklus
Copy link
Contributor

Seeing the same here

@petrklus
Copy link
Contributor

petrklus commented Feb 16, 2022

# 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
Copy link
Contributor

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.

@szabozoltan69
Copy link

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.

@adrien-delhorme
Copy link
Contributor

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

@JohnYan2017
Copy link

any solution? django bug?

@petrklus
Copy link
Contributor

petrklus commented Jul 4, 2022

any solution? django bug?

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

@yakky
Copy link
Member

yakky commented May 25, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants