Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

ToManyField breaks with callable attribute #554

Closed
dstufft opened this Issue · 2 comments

3 participants

Donald Stufft Issac Kelly Vladimir Volodin
Donald Stufft

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

This exception stems from the fact that https://github.com/toastdriven/django-tastypie/blob/master/tastypie/resources.py#L2062 assumes that the attribute will always be a string.

Issac Kelly
Collaborator

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

Vladimir Volodin

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'

Issac Kelly issackelly closed this issue from a commit
Issac Kelly 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
9479190
Matt Hughes hughes referenced this issue from a commit
Commit has since been removed from the repository and is no longer available.
Matt Hughes hughes referenced this issue from a commit
Commit has since been removed from the repository and is no longer available.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.