1
Firstly, your get_all_foo
method is incredibly inefficient, potentially causing thousands of separate database calls. Replace it with:
return ';'.join(D.objects.filter(c__b__a__=self).values_list('foo'))
You can use the same principle to update the D objects from A:
D.objects.filter(c__b__a__=self).update(foo=value)
Source:stackexchange.com