tags:

views:

27

answers:

1

This is my code that fails:

dashboard = Dashboard.objects.get(slug=slug)
users = User.objects.all() # list of users

for editor in dashboard.dashboardeditor_set.iterator:
    users.remove(editor.user)

The error: 'instancemethod' object is not iterable

From models.py:

class DashboardEditor(models.Model):
    dashboard = models.ForeignKey(Dashboard)
    user = models.ForeignKey(User)

Can anybody help me figure out how to scrub editors from the list of all users?

Thanks! :)

+3  A: 

I'd guess from the error message that you are missing parentheses:

 for editor in dashboard.dashboardeditor_set.iterator():

This is because the error message seems to imply that iterator is in instance method so you need to call it to get the actual iterator.

Mark Byers
Yikes. Of course. Thanks for this. :)
Eric