Hi I'm looking to populate a list of members, based on where their club comes from.
This is my code:
members = []
if userprofile.countries.count() > 0:
for c in userprofile.countries.all():
clubs = Club.objects.filter(location__country = c)
for club in clubs:
members_list = Member.objects.get_members(club)
for m in members_list:
members.append(m)
However, when evaluating for m in members_list:
it throws an 'iteration over non-sequence'
I'm not entirely sure why? Can anyone give me any ideas?!
EDIT:
Solved using the following:
members = []
if userprofile.countries.count() > 0:
members_list = member.objects.filter(memberstoentities__club__location__country__in = userprofile.countries.all())
for m in members_list:
members.append(m)