I have two models that are connected by another model through the attitude of many to many.
Here the models themselves
class Posts(models.Model): id = models.CharField(max_length=108, primary_key=True) tags = models.ManyToManyField('Tags', through='PostTags') class Tags(models.Model): id = models.CharField(max_length=108, primary_key=True) posts = models.ManyToManyField('Posts', through='PostTags') class PostTags(models.Model): id = models.CharField(max_length=108, primary_key=True) deleted = models.IntegerField() post_id = models.ForeignKey('Posts', db_column='post_field') tag_id = models.ForeignKey('Tags', db_column='tag_field')
And tastypie resources
class PostsResource(ModelResource): tags = fields.ToManyField('django_app.api.TagsResource', 'tags', null=True) class Meta: queryset = Posts.objects.filter(deleted=0) resource_name = 'posts' class TagsResource(ModelResource): posts = fields.ToManyField('django_app.api.PostsResource', 'posts', null=True) class Meta: queryset = Tags.objects.filter(deleted=0) resource_name = 'tags'
There is a remote flag in the posttags table, is it possible to return only related results when the remote flag in PostTags is 0?
I tried this filter attribute in tastypie, but it seems that it only cares about the flag in the related table (i.e. tags or messages), and not the actual table makes the link.
source share