Hello, I'm new to django, so bear with me if this is a silly approach but, could you assign the project name to db_table at run time? Something like ...
models.py ... # app_name and project_code may need to be declared with global scope ... APP_NAME = 'app_name' # might be optional global project_code = get_project_code(...) def set_project_code(my_project_code): project_code = my_project_code class Measurand(models.Model): project = models.ForeignKey(Project) # project is implied by table name context, so may be unnecessary here? avg_value = models.DecimalField(max_digits=10, decimal_places=4, db_index=True) class Meta: db_table = u'%s_%s_measurand'%( app_name, project_code ) # app_name is usual django behaviour, but may not be necessary if you are certain no other apps will conflict with the table name # another approach would be ... # db_table = u'%s_measurand'%( project_code ) ... Obviously, before you build project tables, you'd need to call et_project_code HTH
-- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.