Django: How to migrate dynamic models made at runtime

前端 未结 2 1431
旧时难觅i
旧时难觅i 2021-02-20 04:58

In my Django app, a specific user input will result in the creation of a new model. Here is the code I am using to create the model and register it.

model = type         


        
2条回答
  •  情话喂你
    2021-02-20 05:41

    A simple solution worked for me. I ended up running the makemigrations and migrate management commands like so, after creating the dynamic model:

    from django.core.management import call_command
    call_command('makemigrations')
    call_command('migrate')
    

提交回复
热议问题