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

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

Posted by: admin November 30, 2017 Leave a comment

Questions:

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.

Answers:

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

model_instance._meta.db_table