toastdriven/django-tastypie — Issue #322: Improve the way that nested resource are built
Author: jorgeecardona
Created: 2012-01-02 03:59:01+00:00
State: open

Hi

I'm trying to create a nested resource with a uri like "/parents/1/childs/1" and I want to GET, POST, PUT and DELETE on them but is not really easy to also check permissions and more. I was trying to code something using the fields "ToManyField" but I was dealing with some reverse url problems, maybe someone can think in a better way to create this nested resources.

My ideas are:

1 - A nested resource (child) it can be declared using the ToManyField adding some: nested=True, or resource=NestedResource.
2 - Since a nested resource implies the existence of a parent object, some way to pass this parent object to the child resource must be defined in order to built the queryset and more attributes of the resource like validators etc.
3 - I don't know if we need change in the way the url_base is built, because in the url we will have two "resource_name" and two "pk" on it, and reverse will not work.

I hope someone has some better ideas on this.