I know that the same question was asked earlier, but I was hoping for a "better" answer (which does not include modifying class attributes at runtime). It was a question:
Single Django model, multiple tables?
I have the same problem. I am looking for a solution similar to the defendant's first answer, but it really works. If there is no better solution, can anyone comment on how reliable the defendant’s decision is? It seems to me that the delay between changing the database name and the database query can lead to the return of results from the wrong table:
request 1: change name
query 2: change name again
query 1: get results (but using the wrong name from query 2)
Edit: the model is intended for use on ~ 15 tables - therefore, inheritance is impractical, since each time a new model name is required.
thanks
PS We apologize if this is not the right way to ask for a question.
user908085
source share