toastdriven/django-tastypie — pull request #921 by willembult (2013-04-26 01:53:54+00:00)
Title: Allow filtering against foreign resources by using the resource URI

The resource URI is used in multiple places to reference ModelResources, rather than the primary key. In filtering against a related ModelResource though, the primary key can be used, but not the resource uri. This patch adds that ability.

An example use case is given below.

```python
class UserResource(ModelResource):
class Meta:
resource_name = 'user'
allowed_methods = ['get']
queryset = User.objects.all()

class BlogPostResource(ModelResource):
user = fields.ToOneField(UserResource, 'user')

class Meta:
resource_name = 'blogpost'
allowed_methods = ['get']
queryset = BlogPost.objects.select_related('user')
fields = ('title','content')
filtering = {'user': ALL_WITH_RELATIONS}
```

A result from [/api/v1/user?format=json](javascript:void\(0\)) might say:
```javascript
{"meta": {"limit": 20, "next": null, "offset": 0, "previous": null, "total_count": 2}, "objects": [{"resource_uri": "/api/v1/user/1", "name": "Joe"},{"resource_uri": "/api/v1/user/2", "name": "Tom"}]}
```

We can then GET [/api/v1/blogpost?user=/api/v1/user/1&format=json](javascript:void\(0\)) to get the blog posts by Joe.