I'm building an API with tastypie for a django app for data based on the user. The resources are like this:
class PizzaResource(ModelResource):
toppings = fields.ToManyField(
'project.app.api.ToppingResource',
'topping_set'
)
class Meta:
authentication = SessionAuthentication()
queryset = Pizza.objects.all()
def apply_authorization_limits(self, request, object_list):
return object_list.filter(users=request.user)
class ToppingResource(ModelResource):
pizza = fields.ForeignKey(PizzaResource, 'pizza')
class Meta:
authentication = SessionAuthentication()
queryset = Topping.objects.filter()
The according models are like this:
class Pizza(model):
users = ManyToManyField(User)
toppings = ManyToManyField(Topping)
# other stuff
class Topping(Model):
used_by = ManyToManyField(User)
# other stuff
Now what I want to do is filter the toppings
listed with pizza
by the Topping.used_by
field. I just found how to filter this field by request unrelated data.
How can I filter a relationship field of tastypie
by request data?