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! 🙂
I’d guess from the error message that you are missing parentheses:
This is because the error message seems to imply that
iteratoris in instance method so you need to call it to get the actual iterator.