Denigma
hevok @hevok October 27, 2012
Tutorial #django

Referencing Model Instance Fields Dynamically

To update an prior undeclared model instance using a fields dictionary settattribute can be used::

for k,v in fields.iteritmes():
   setattr(instance, k, v

In the case of ManyToMany relationship attributes its counterpart gettattribute comes in handy::

getattr(instance, k).add(related[Object](/blog/562/))