如何将 Django 模型外键字段限制为相同模型的过滤列表

How to limit Django Model foreign key field to filtered list of same Model

这是我正在使用的模型,我想按类型过滤质量控制

class ServiceCenter(models.Model):  
    name = models.CharField(max_length=30)  
    type = models.CharField(max_length=30)  
    city = models.ForeignKey(City)
    qc = models.ForeignKey(ServiceCenter, null=True, blank=True, limit_choices_to=ServiceCenter.objects.filter(type="Some type"))  

看看 Django 文档,他们对此很清楚:

https://docs.djangoproject.com/en/1.8/ref/models/fields/#django.db.models.ForeignKey.limit_choices_to

这将完成工作:

limit_choices_to={'type':"Some type"}