Object does not support item assignment error Object does not support item assignment error django django

Object does not support item assignment error


The error seems clear: model objects do not support item assignment.MyModel.objects.latest('id')['foo'] = 'bar' will throw this same error.

It's a little confusing that your model instance is called projectForm...

To reproduce your first block of code in a loop, you need to use setattr

for k,v in session_results.iteritems():    setattr(projectForm, k, v)


Another way would be adding __getitem__, __setitem__ function

def __getitem__(self, key):    return getattr(self, key)

You can use self[key] to access now.