Oct. 2, 2012 -
The way Django Tastypie explains nested resources in their documentation is somewhat ackward and comes with several drawbacks:
- Authentication simply does not work.
- You are repeating yourself with object not found and multiple objects found checks.
The alternative approach they describe suddenly asks you to change your main urls.py. Weird.
Instead of doing what is described in the Tastypie cookbook regarding nested resources, you can achieve the same thing with more elegant code:
def override_urls(self): # prepend_urls in 0.9.12
url(r'^(?P<resource_name>%s)/(?P<pk>\w[\w/-]*)/child%s$' % (
def dispatch_child(self, request, **kwargs):
return ChildResource().dispatch('list', request, **kwargs)