I have a large number of sets of data. Each set of data comprises of several database tables. The schema for the sets of database tables is identical. Each set of tables can have over a million rows. Each set of data belongs to one job, there are no relations between jobs. One or more jobs belong to a different user. Sets of tables get imported and eventually deleted as a set of tables. From a performance point of view it is better to keep them as separate sets of tables.
So I would like to have several generic Django models one for each of the several tables.
I have achieved it in my views.py file by using code similar to this:
from foobar.models import Foo, Bar
def my_view(request):
prefix = request.GET.get('prefix')
Foo._meta.db_table = prefix + '_foo'
Bar._meta.db_table = prefix + '_bar'