KaronatoR
KaronatoR

Reputation: 2653

Django Tastypie: instancemethod object is not iterable

Trying to add ToManyField to the resource. Here is the model:

class Project(models.Model):
...
def access_set(self):
    return User.objects.all()

Here is the resource:

class ProjectResource(ModelResource):
...
access = fields.ToManyField(UserResource, attribute = 'access_set', readonly=True, null=True)
...

I have the error: 'instancemethod' object is not iterable

Any thoughts please?

Upvotes: 0

Views: 251

Answers (1)

jbasko
jbasko

Reputation: 7330

It feels like it could be expecting access_set to be a @property:

class Project(models.Model):

    ...

    @property
    def access_set(self):
        return User.objects.all()

Upvotes: 1

Related Questions