Allow traversing nullable related fields by gcbirzan · Pull Request #5849 · encode/django-rest-framework (original) (raw)
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 andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Conversation2 Commits1 Checks0 Files changed
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
[ Show hidden characters]({{ revealButtonHref }})
This allows you to have a related field that traverses nullable relations. A default is required to have the value in the output, but the current behaviour is to throw an AttributeError.
Closes #5848
Hi @gcbirzan. This looks very much in line with the other changes we've made thus far here, following from #5375.
I just want to look at the test case a little more closely. Specifically, how it differs from the test case in #5880 and whether we can combine the two.
Hi @gcbirzan.
The difference in the tests was just exactly that you're one was using RelatedField
whereas the previous one had used an CharField
.
I adjusted the test to use the existing models. This looks good to me. Thanks for the input!
pchiquet pushed a commit to pchiquet/django-rest-framework that referenced this pull request
2 participants