Answer the question
In order to leave comments, you need to log in
Dynamic table name change via _meta model attribute?
I did not find an attribute or model method that could dynamically set the table name for the model. Therefore, I decided to change through the hidden _meta attribute of the model. I change the table name dynamically, because there is a partitioning on a certain field
. Are there any side effects?
class Test(models.Model):
number = models.IntegerField("Партицируемый атрибут", default=0)
class Meta:
db_table = 'test'
Test._meta.db_table = "test_1"
Test.objects.all()
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question