Skip to content

Included field might not be set #172

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

Merged
merged 2 commits into from
Dec 14, 2015
Merged

Included field might not be set #172

merged 2 commits into from
Dec 14, 2015

Conversation

lukaslundgren
Copy link
Contributor

I have three models:

  • Account
  • AccountTypeA
  • AccountTypeB

AccountTypeA/AccountTypeB each have a OneToOneField to Account. Account can only be of type A or B, not both. In my AccountSerializer I've included the attributes for both the reversed relationships. I've also included the AccountTypeA/AccountTypeB serializers in included_serializers.

extract_included expects both fields to be present on every account instance when in reality each account will have either the A or B relation. This pull request makes extract_included to ignore missing fields.

@jsenecal
Copy link
Member

Could you please update the example for that specific use case and add appropriate tests ?

@lukaslundgren
Copy link
Contributor Author

Sure, I've added my first attempt at this.

jerel added a commit that referenced this pull request Dec 14, 2015
Included field might not be set
@jerel jerel merged commit d5e1227 into django-json-api:develop Dec 14, 2015
@jerel
Copy link
Member

jerel commented Dec 14, 2015

This looks good to me now. Thanks for the PR!

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.

3 participants