Django - How can Django ORM manage user's uploaded tables in database -
my web application allow users load/create tables in postgres database. know django orm needs model definition in models.py each table in database access it. how can access user's uploaded tables in app without creating new model definition on fly each time new table uploaded? thinking creating generic model definition decompose table components this:
models.py
class table(models.model): filename = models.charfield(max_length=255) class attribute(models.model): table = models.foreignkey(table) name = models.charfield(max_length=255) type = models.integerfield() width = models.integerfield() precision = models.integerfield() class row(models.model): table = models.foreignkey(table) class attributevalue(models.model): row = models.foreignkey(row) attribute = models.foreignkey(attribute) value = models.charfield(max_length=255, blank=true, null=true)
the problems such generic model every tables mixed in 4 table (not useful in admin interface) , slow create when have lot of rows. have suggestion case?
edit: viable use separate database store tables , use router , manage.py inspectdb
update models.py each time user add or delete table? (like in post) wonder happen if 2 users add table in same time?
i think should dynamic models here:
https://code.djangoproject.com/wiki/dynamicmodels
or here:
http://dynamic-models.readthedocs.org/en/latest/
good luck because not easy way friend :)
Comments
Post a Comment