In my Django application, certain user input will lead to the creation of a new model. Here is the code that I use to create the model and register it.
model = type(model_name, (ExistingModel,), attrs) admin.site.register(model, admin_options) from django.core.urlresolvers import clear_url_caches from django.utils.module_loading import import_module reload(import_module(settings.ROOT_URLCONF)) clear_url_caches()
This successfully creates a new model, however, when I click on the model to see the table on the admin page, I get the following error:
relationship "ExistingModel_NewModel" does not exist
This usually means that new model changes have not been carried forward. How to transfer dynamically created models to Django to see their respective data tables?
source share