How to read the database table name of a Model instance?

后端 未结 1 646
抹茶落季
抹茶落季 2021-01-31 13:02

Given a model\'s instance object, how can I get the database table\'s name?

I don\'t want to specify names explicitly in the Meta class.

1条回答
  •  北恋
    北恋 (楼主)
    2021-01-31 13:46

    Found the answer myself: the _meta attribute of an instance has the information:

    model_instance._meta.db_table
    

    0 讨论(0)
提交回复
热议问题