I want to store a dict in Django. a very basic solution would be this:
class foo(models.Model):
    bar = models.TextField()
fooInstance.bar = json.dumps(my_dict)
but I wanted to be able to access it directly and not constantly use json, so I did the following:
class foo(models.Model):
    _bar = models.TextField()
    @property
    def bar(self):
        import json
        return json.loads(self._bar)
    @bar.setter
    def bar(self, new_bar):
        import json
        self._bar = json.dumps(new_bar)
fooInstance.bar = my_dict
and this works for the most part, only that I can't do one thing:
fooInstance.bar['key'] = 'value'
this expression goes through, no error. but the value is not being set. does anybody has any ideas on how this could be done?
Any help is appreciated.