I'm trying to populate a list based on partiular members, but it doesn't seem to be going to plan.
user = request.user
members = []
userprofile = user.get_profile()
if user.is_superuser or user.is_staff:
if userprofile.countries.count() == 0:
members = Member.objects.all()
elif userprofile.countries.count() >0:
for c in userprofile.countries.all():
m1 = Member.objects.filter(location__country = c)
members.append(m1)
else:
pass
self.fields['members'].choices = [(member.id, member.display_name()) for member in members]
Here, we see self.fields (it's a multi-select box) has member.id. I've tried both this and member.pk, but it doesn't seem to be working => Django informs me member has no attributes called id or pk
If a user is a superuser and has a countries count of 0, then It works fine; So i know its to do with the append function underneath the queryset call.
Could anyone offer any hints as to why id/pk is unavailable/lost after adding the results to a list? In addition, does anyone know of a workaround?