我有一个简单的多对多关系概述如下:
class Client(models.Model):
"""
just stores a Client hostname now
"""
hostname = models.CharField(max_length=250, null=False, blank=False, unique=True)
def __unicode__(self):
"""
"""
return str(self.hostname)
class Run(models.Model):
clients = models.ManyToManyField(Client)
使用 django-rest-framework 我现在有过滤器可以识别特定的客户端:
"/api/runs/?clients=1" 工作并检索所有与主键为 1 的客户端的运行。
如何启用允许 "/api/runs/?clients=myhostname" 的过滤器?