Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Relation fields no to_fields attribute attribute break serializer #3634

Closed
martinhill opened this issue Nov 14, 2015 · 3 comments
Closed

Relation fields no to_fields attribute attribute break serializer #3634

martinhill opened this issue Nov 14, 2015 · 3 comments
Labels
Milestone

Comments

@martinhill
Copy link

Hello,

I have a ModelSerializer for the django-taggit package's Tag model. With DRF release 3.3.1 it began failing with AttributeError: 'TaggableManager' object has no attribute 'to_fields'.

I believe this line from PR 3526 assumes all relation fields have a to_fields attribute, but taggit's TaggableManager is an example of one that doesn't.

Replacing it with

    return field.to_fields[0] if hasattr(field, 'to_fields') else None

seems to solve the problem.

@xordoquy xordoquy added this to the 3.3.2 Release milestone Nov 14, 2015
@xordoquy xordoquy added the Bug label Nov 14, 2015
@xordoquy
Copy link
Collaborator

Seems sensible to me.

@jpadilla
Copy link
Member

@martinhill wan't to put a PR together with your proposed changes?

@martinhill
Copy link
Author

be happy to!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants