如何读取Model实例的数据库表名称? [英] How to read the database table name of a Model instance?

查看:110
本文介绍了如何读取Model实例的数据库表名称?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

给出模型的实例对象,如何获得数据库表的名称?

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

我不想在Meta类中明确指定名称。

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

推荐答案

我自己找到了答案:实例的_meta属性具有以下信息:

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

model_instance._meta.db_table

这篇关于如何读取Model实例的数据库表名称?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆