Need help about django query--one model with many tables

i have to create lots of tables shared one model.
Model like this:

class MDR_Design(models.Model):

then , create table with pymysql connection

cur.execute("create table " + projCode + " select * from appname_mdr_design where 1=2")

then ,i have tables: table001,table002,…

in the views:


and at this time ,error raised like this:

**(1054, "Unknown column 'table001.col_file_no' in 'field list'")**

how to handle this problem, thank you very very much

You’re not really clear here on what all you’re really trying to achieve by this. My initial reaction to what you have posted is that it appears to me you’re trying to copy a pattern you’ve seen or used in a different application, to Django - when it may not be appropriate to do so directly.

But aside from that, Django expects the tables to exist when it starts. Django is not designed to provide for creating tables while it’s up and running. Django expects you to have your models defined first. Then, you can use makemigrations and migrate to create the tables before starting the web service.

But in general, you can create multiple models from a single abstract model. You could create your MDR_Design model as an abstract class and then create your subclasses from it.