Tastypie, filtering many to many relationships

后端 未结 2 564
渐次进展
渐次进展 2021-02-09 15:08

I have two models that are linked by another model through a many to many relationship.

Here\'s the models themselves

class Posts(models.Model):
    id =         


        
2条回答
  •  梦毁少年i
    2021-02-09 16:03

    You can filter fields using lambda bundle attribute showing table name and field name.

    tags = fields.ToManyField('django_app.api.TagsResource', attribute=lambda bundle: bundle.obj.tags.filter(tags__deleted=0))

提交回复
热议问题