【问题标题】:Show the table name in database regarding the model in django在 django 中显示关于模型的数据库中的表名
【发布时间】:2021-02-14 23:37:25
【问题描述】:

我必须在我的项目中找到对应模型的数据库表名,我该怎么做。我之前尝试过


 class Meta:
        db_table = 'tablenameIWant'

但是我怎样才能看到表名呢?

【问题讨论】:

    标签: python python-3.x django database django-models


    【解决方案1】:

    模型的 Meta 类可以通过 _meta 属性访问。 所以:

    MyModel._meta.db_table
    

    【讨论】:

      猜你喜欢
      • 2012-06-05
      • 1970-01-01
      • 2012-02-17
      • 2011-11-09
      • 2022-11-24
      • 1970-01-01
      • 2013-01-18
      • 1970-01-01
      • 2011-11-19
      相关资源
      最近更新 更多