How to loop over my Django-filter result? Please help me!

108 views
Skip to first unread message

Prabu DNC Chits

unread,
Apr 5, 2020, 5:09:56 PM4/5/20
to django-filter
def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
context['filter'] = PoFilter(self.request.GET, queryset=self.get_queryset().order_by('processed'))
for item in context['filter']:
print(item.name)
return context

im getting error that the filter is not iterable

Wim Feijen

unread,
Apr 6, 2020, 5:06:33 AM4/6/20
to django-filter
Hi Prabu,

You can loop over the objects using:

for item in context['filter'].qs :


Good luck!

Wim




Op zondag 5 april 2020 23:09:56 UTC+2 schreef Prabu DNC Chits:
Reply all
Reply to author
Forward
0 new messages