[Answered ]-Django Tastypie Generic Relation

2👍

✅

Its a bit tricky since there is 2 way relationship with ContentTypes flying around. I guess this would help :

class WorkResource( BaseModelResource ):
    links = fields.ToManyField('musiclibrary.api.LinkResource', attribute=lambda bundle: Link.objects.filter(entity0_content_type=ContentType.objects.get_for_model(bundle.obj), entity0_object_id=bundle.obj.id))

Leave a comment