2013-12-17 18 views

cevap

6

ContentType yalnızca django uygulamanızdaki diğer tüm tablolar/modeller hakkında bilgi içeren veritabanındaki model ve çizelgedir.

Postgres tablosu: Postgres'e içinde

=> \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 

veri:

Örneğin
=> 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 
... 

, kendi uygulamanızda özel yönetici inşa etmek ve ContentType kullanabilirsiniz tabloların listesini almak istiyorsanız model:

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

Usecases için django admin kaynaklarını denetleyin, ContentTypes acti orada kullanılan vely.

İlgili konular