shourav shourav - 3 years ago 219
MySQL Question

Dynamic table and model generate in django

I want to create some database tables and

on api call in django. I created on demand Model

model = type(str(project_slug + "_tbl_name"), (models.Model,), attrs)

and I want to create table like this

db.create_table(table_name, fields)

create_table was from south
but south is not available in Django 1.11 what I am using

How can I generate Model and database tables programmatically?

Answer Source


with connection.schema_editor() as schema_editor:
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download