Skip to content
This repository has been archived by the owner on Jul 6, 2023. It is now read-only.

Specifying ModelResource Relationships in TastyPie

Colorado Reed edited this page Feb 8, 2014 · 2 revisions

ForeignKey

e.g. for ConceptResourceResource

# api
class ConceptResourceResource(CustomReversionResource):
    concept = fields.ToOneField("apps.graph.api.ConceptResource", "concept")

class ConceptResource(CustomReversionResource):
    resources = fields.ToManyField(ConceptResourceResource, 'concept_resource', full=True, related_name="concept")

# models
class Concept:
    # no mention of ConceptResource

class ConceptResource:
    concept = ForeignKey(Concept, related_name="concept_resource")

NB: you do not need to specify concept in the conceptresource resource