views:

32

answers:

2

I'd like to do the following:

for table in table_list:
   'table'.samefield = newvalue
+2  A: 

If you know the name of the application that it's in, then you can do

model = getattr(application_name.models, 'table')
model.somefield = newvalue

or just

getattr(application_name.models, 'table').somefield = newvalue

if you only want to access it once (although that doesn't really make any sense).

aaronasterling
nice solution if the application name is known.
anand
A: 

You can use the django contenttypes framework for this. Have a look at this link:

http://docs.djangoproject.com/en/dev/ref/contrib/contenttypes/

anand