Django Tastypie wirft eine 'maximale Rekursionstiefe überschritten', wenn voll = True bei umgekehrter Beziehung.
Ich erhalte eine maximale Rekursionstiefe, die überschritten wird, wenn der folgende Code ausgeführt wird:
from tastypie import fields, utils
from tastypie.resources import ModelResource
from core.models import Project, Client
class ClientResource(ModelResource):
projects = fields.ToManyField(
'api.resources.ProjectResource', 'project_set', full=True
)
class Meta:
queryset = Client.objects.all()
resource_name = 'client'
class ProjectResource(ModelResource):
client = fields.ForeignKey(ClientResource, 'client', full=True)
class Meta:
queryset = Project.objects.all()
resource_name = 'project'
# curl http://localhost:8000/api/client/?format=json
# or
# curl http://localhost:8000/api/project/?format=json
Wenn eine Menge voll = Falsch für eine der Relationen ist, funktioniert sie. Ich verstehe, warum dies geschieht, aber ich brauche beide Beziehungen, um Daten zu liefern, nicht nur die "resource_uri". Gibt es eine Tastypie-Möglichkeit? Ich habe es geschafft, das Problem beim Erstellen einer Serialisierungsmethode für mein Projektmodell zu lösen, aber es ist alles andere als elegant. Vielen Dank.