2013-12-17 2 views

답변

6

ContentType은 django 응용 프로그램의 다른 모든 테이블/모델에 대한 정보가 들어있는 데이터베이스의 모델 및 테이블입니다.

포스트 그레스 테이블 : 포스트 그레스에서

=> \d django_content_type; 

    Column |   Type   |       Modifiers 
-----------+------------------------+----------------------------------------- 
id  | integer    | not null ... 
name  | character varying(100) | not null 
app_label | character varying(100) | not null 
model  | character varying(100) | not null 

데이터 :

예를 들어
=> SELECT * from django_content_type; 

id |   name   |  app_label  |  model   
----+-----------------------+-------------------+--------------------- 
    1 | permission   | auth    | permission 
    2 | group     | auth    | group 
    3 | user     | auth    | user 
    4 | auth user groups  | auth    | authusergroups 
... 

, 당신은 당신의 응용 프로그램에서 사용자 지정 관리자를 구축하고, 당신이 ContentType을 사용할 수있는 테이블의 목록을 얻으려면 모델 :

>>> from django.contrib.contenttypes.models import ContentType 
>>> tables = ContentType.objects.filter(app_label="my_app") 

사용중인 django 관리 소스, ContentTypeacti 거기에서 사용되었다.

관련 문제