2013-02-26 2 views
0

메 자닌을 사용합니다. 이 모델이 있습니다쿼리 유형을 필드 유형별로 필터링하는 방법

내가 content_object 필드의 유형 Post 모든 독특한 AssignedKeyword 모델 인스턴스를 가져올 지
class AssignedKeyword(Orderable): 
    """ 
    A ``Keyword`` assigned to a model instance. 
    """ 

    keyword = models.ForeignKey("Keyword", related_name="assignments") 
    content_type = models.ForeignKey("contenttypes.ContentType") 
    object_pk = models.IntegerField() 
    content_object = GenericForeignKey("content_type", "object_pk") 

    class Meta: 
     order_with_respect_to = "content_object" 

    def __unicode__(self): 
     return unicode(self.keyword) 

. 쿼리 유형을 필드 유형별로 필터링하려면 어떻게합니까?

답변

0

대답은 간단했다 :

AssignedKeyword.objects.filter(content_type=ContentType.objects.get(name='Product')) 
관련 문제