Django; How can i change the table name used by i.

2019-05-18 05:25发布

How can i change the info in the Meta class in i.e 'django.contrib.sessions.models' , so that my project can have somewhat uniform table names, but so that the functionality of the app is the same?

Thanks

1条回答
Emotional °昔
2楼-- · 2019-05-18 06:20

You can try this:

from django.contrib.sessions.models import Session
Session.Meta.db_table = 'my_session'

EDITED The above solution throws an error but the following works:

from django.contrib.sessions.models import Session
Session._meta.db_table = "my_session"
查看更多
登录 后发表回答