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

Support for GenericRelation #34

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

blturner
Copy link
Contributor

This introduces support for GenericRelation fields.

@@ -872,6 +872,16 @@ def _to_basic_type(self, obj, field):
if isinstance(field, models.ManyToManyField):
return eval(field.value_to_string(obj))

if isinstance(field, models.related.RelatedObject):
for virtual_field in self.Meta.model._meta.virtual_fields:
if virtual_field.name == 'content_object':
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This obviously needs to not be hardcoded. It seems like exposing this field might require it's own field where we specify the name of the attribute to look up. Otherwise, I'm wondering if we're better off just hiding this attribute from the response data.

@blturner
Copy link
Contributor Author

Ah, tests are failing on this branch because I'm using Django 1.7 locally and django.contrib.contenttypes.fields doesn't exist pre-1.7.

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.

1 participant