Dynamically change db_table django Meta

Sorry for my English

I have a table to manage list of database configurations. Table post in all db have same fields but different name. Eg. table post name is md_post, table post in other db is tdt_post. So, when I access a db configuration I want to remote that database. I did it! But how can I change tb_name in Meta Django Model?

These Datatables configurations are non-permanent and may change when I add/update/delete record.

I tried it, but it only works one time.

Post._meta.db_table = `tdt_post`
Post._meta.original_attrs['db_table'] = `tdt_post`

When I change the db_table back to 'md_post', it doesn't work.

I have looked at the following posts, but it doesn't solve my problem: Django model: change db_table dynamically, Change table name for django model in runtime

Back to Top