My web application allow users to load/create tables in the Postgres database. I know Django ORM needs a model definition in models.py for each table in the database to access it.
I wonder if I could call manage.py inspectdb from a script after an upload (or a delete) to auto-generates the models.py.
If I use queues with django-celery to be sure that every inspectdb are done one at a time, could it be a viable solution?
Thank you for your comments and suggestions!
Well you can call commands with
from django.core import management
management.call_command('inspectdb')
see here for more info.
But I doubt it would work for dynamically creating models the way you want. For one thing, most wsgi servers need to be rebooted for changes to appear.