ToManyField breaks with callable attribute #554

dstufft opened this Issue Jul 11, 2012 · 2 comments

3 participants


When attempting to use a callable as the atribute for a ToManyField a TypeError is thrown.

This exception stems from the fact that assumes that the attribute will always be a string.


Is that the root of your traceback? I assume this is; can you point out the resource and the call?


I have a model with many-to-many relationship through another model. In order to get this relationship's data on GET I had to use 'attribute':
assignee = fields.ManyToManyField(UserResource, full=True, null=True, attribute=related_users_fun)

related_users_fun is a function

But now when I try to POST I get the exception saying 'getattr(): attribute name must be string'

@issackelly issackelly added a commit that closed this issue Aug 11, 2012
@issackelly issackelly Approved patches for fixing callable attributes on ToOneField and ToM…
…anyField. Thanks Donald Stufft and Valdimir Volodin for the fixes, and pennersr and sgarcez, for reports.

Closes #347
Closes #355
Closes #554
Closes #608
Closes #609
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment