django _meta方法

 1 models.Book._meta.'concrete_model':  <class 'books.models.Book'>
 2 models.Book._meta.'related_fkey_lookups':  []
 3 models.Book._meta.'get_latest_by':  None
 4 models.Book._meta.'verbose_name':  book
 5 models.Book._meta.'_forward_fields_map':  {'publisher': , 'publisher_id': , 'publication_date': , 'id': , 'authors': , 'title': }
 6 models.Book._meta.'db_tablespace':  
 7 models.Book._meta.'swappable':  None
 8 models.Book._meta.'local_fields':  [, , , ]
 9 models.Book._meta.'_get_fields_cache':  {(True, False, True, False, True): (, , , , ), (True, False, False, False, True): (, , , , )}
10 models.Book._meta.'unique_together':  []
11 models.Book._meta.'apps':  
12 models.Book._meta.'verbose_name_plural':  books
13 models.Book._meta.'object_name':  Book
14 models.Book._meta.'original_attrs':  {}
15 models.Book._meta.'required_db_features':  []
16 models.Book._meta.'model':  <class 'books.models.Book'>
17 models.Book._meta.'proxied_children':  []
18 models.Book._meta.'auto_field':  books.Book.id
19 models.Book._meta.'pk':  books.Book.id
20 models.Book._meta.'_ordering_clash':  False
21 models.Book._meta.'managed':  True
22 models.Book._meta.'permissions':  []
23 models.Book._meta.'managers':  [(22, , False)]
24 models.Book._meta.'required_db_vendor':  None
25 models.Book._meta.'virtual_fields':  []
26 models.Book._meta.'abstract':  False
27 models.Book._meta.'proxy':  False
28 models.Book._meta.'has_auto_field':  True
29 models.Book._meta.'order_with_respect_to':  None
30 models.Book._meta.'default_permissions':  ('add', 'change', 'delete')
31 models.Book._meta.'fields':  (, , , )
32 models.Book._meta.'app_label':  books
33 models.Book._meta.'auto_created':  False
34 models.Book._meta.'parents':  OrderedDict()
35 models.Book._meta.'ordering':  []
36 models.Book._meta.'proxy_for_model':  None
37 models.Book._meta.'local_many_to_many':  []
38 models.Book._meta.'model_name':  book
39 models.Book._meta.'index_together':  []
40 models.Book._meta.'_relation_tree':  []
41 models.Book._meta.'default_related_name':  None
42 models.Book._meta.'select_on_save':  False
43 models.Book._meta.'db_table':  books_book

 

 1 for method in get_model._meta.__dict__:
 2                 if hasattr(get_model._meta, method):
 3                     get_method = getattr(get_model._meta, method)
 4                     print("++++++++++%s._meta.%s: type: %s++++++++++" % (get_model, method, type(get_method)))
 5                     if type(get_method) in (list, tuple):
 6                         for obj in get_method:
 7                             print(str("-----\t").expandtabs(8), obj)
 8                     else:
 9                         if type(get_method) == dict:
10                             for key, value in get_method.items():
11                                 print(str("-----\t").expandtabs(8), key, value, type(value))
12                         else:
13                             print(str("-----\t").expandtabs(8), get_method)

 

转载于:https://www.cnblogs.com/zengchunyun/p/5485250.html

你可能感兴趣的:(django _meta方法)