So you are casually overriding get_queryset()
in a, say, ListView, like this:
def get_queryset(self):
entries = [x for x in Entry.objects.all() if x.publications]
return entries
Because you need to sort the Entry
table by a reverse M2M relation publications
and then BAM!:
Attribute error 'list' object has no attribute 'filter'
Without a trace of the line you made a mistake in…
The problem is that the get_queryset()
needs to return a QuerySet (lol). So the error is raised when Django is checking if it can apply basic methods to what get_queryset()
returns.
So to transform your generated list to QuerySet do this:
def get_queryset(self):
def_entries = [x.pk for x in Entry.objects.all() if x.publications]
entries = Entry.objects.filter(pk__in=def_entries)
return entries
Merely a lack of concentration. Where is my coffee… ☕💤🧸
Thank you so much!
LikeLiked by 1 person
You are welcome 🙂
LikeLike