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': <django.db.models.fields.related.ForeignKey: publisher>, 'publisher_id': <django.db.models.fields.related.ForeignKey: publisher>, 'publication_date': <django.db.models.fields.DateField: publication_date>, 'id': <django.db.models.fields.AutoField: id>, 'authors': <django.db.models.fields.related.ManyToManyField: authors>, 'title': <django.db.models.fields.CharField: title>} 6 models.Book._meta.'db_tablespace': 7 models.Book._meta.'swappable': None 8 models.Book._meta.'local_fields': [<django.db.models.fields.AutoField: id>, <django.db.models.fields.CharField: title>, <django.db.models.fields.related.ForeignKey: publisher>, <django.db.models.fields.DateField: publication_date>] 9 models.Book._meta.'_get_fields_cache': {(True, False, True, False, True): (<django.db.models.fields.AutoField: id>, <django.db.models.fields.CharField: title>, <django.db.models.fields.related.ForeignKey: publisher>, <django.db.models.fields.DateField: publication_date>, <django.db.models.fields.related.ManyToManyField: authors>), (True, False, False, False, True): (<django.db.models.fields.AutoField: id>, <django.db.models.fields.CharField: title>, <django.db.models.fields.related.ForeignKey: publisher>, <django.db.models.fields.DateField: publication_date>, <django.db.models.fields.related.ManyToManyField: authors>)} 10 models.Book._meta.'unique_together': [] 11 models.Book._meta.'apps': <django.apps.registry.Apps object at 0x1038e1e10> 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, <django.db.models.manager.Manager object at 0x104f7e128>, 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': (<django.db.models.fields.AutoField: id>, <django.db.models.fields.CharField: title>, <django.db.models.fields.related.ForeignKey: publisher>, <django.db.models.fields.DateField: publication_date>) 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': [<django.db.models.fields.related.ManyToManyField: authors>] 38 models.Book._meta.'model_name': book 39 models.Book._meta.'index_together': [] 40 models.Book._meta.'_relation_tree': [<django.db.models.fields.related.ForeignKey: book>] 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)
本站文章如无特殊说明,均为本站原创,如若转载,请注明出处:django _meta方法 - Python技术站