2013-07-28 1 views
0

에서 제네릭 형식에서 객체를 검색 할 수 없습니다 :내가과 같이 일반 객체를 검색하려고 장고

generic_type = ContentType.objects.get(app_label="customers", model="Customer") 
print generic_type.id 
print 'customer: '+str(customer.id) 
setting = generic_type.get_object_for_this_type(object_id=customer.id) 

모두 인쇄 문 내 데이터베이스에 저장된 적절한 값을 뱉어. 내가 장고 1.4.3

를 실행하고 https://docs.djangoproject.com/en/dev/ref/contrib/contenttypes/#django.contrib.contenttypes.models.ContentType

내 검색 방법 문제 있나요 : 여기에 문서에서 발견

나는 검색을 다음 무엇입니까? 당신이 장고 1.4을 사용하는 경우

generic_type = ContentType.objects.get_for_model(customer) 
setting = Preference.objects.filter(content_type__pk=generic_type.id, object_id=customer.id) 
+0

은 다음 장고 1.4의 워드 프로세서를 사용한다,하지 최신 개발 문서 : https://docs.djangoproject.com/en – stefanw

+0

이 인스턴스에서는 동일합니다. – Atma

답변

0

은 다음과 같이 수행 할 수 있습니다 /1.4/