从默认设置继承并重命名 table

Inherit and rename the table from default setting

我想重命名默认值 table 来自 Django。 Meta 确实复制了 table 但列完全不同 我怎么能接受呢?

发生这种情况的原因是因为 Session 是一个具体的模型。这里发生的是您指定要 继承 Session table。这是在 SQL 层中实现的,方法是创建一个新的 table,除了额外的字段外,还包含父 table 的 OneToOneField,此外,它还充当主要的关键也是。有关 Django 如何处理模型继承的更多信息,请参阅 Multi-table inheritance in the documentation.

部分

如果你想实现自己的会话模型,你应该继承SessionStoreAbstractBaseSession model [Django-doc]. This is an abstract model that has as fields sesion_key, session_data and expire_date. You can then override or "monkey patch" the get_model_class