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

RelatedField return empty strings instead of None #536

Closed
wants to merge 1 commit into from

Conversation

fao89
Copy link
Member

@fao89 fao89 commented Feb 11, 2020

@fao89 fao89 requested a review from dkliban February 11, 2020 21:47
# Return empty string instead of None
try:
attr = get_attribute(instance, self.source_attrs)
except Exception:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What kind of exception is possible here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fao89
Copy link
Member Author

fao89 commented Feb 12, 2020

This PR is a PoC, I don't know if the best approach is changing _DetailFieldMixin, maybe a better option would be creating a specific field for it like StringDetailRelatedField. I just wanted to see how bindings would behave if instead of getting None it received an empty string.
It seems to work, as you can see on the gist:
https://gist.github.com/fabricio-aguiar/40eef40aec26feae1c3f03c515c4ca73

@fao89 fao89 closed this Feb 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants