title: How to set django model field by name?
body: <p>This seems like it should be dead simple, so I must be missing something. I just want to set the value of a field in my model instance by name. Say I have:</p>
  
  <pre><code>class Foo(Model):
    bar = CharField()
  
  f = Foo()
  </code></pre>
  
  <p>I want to set the value of bar by name, not by accessing the field. So something like:</p>
  
  <pre><code>f.fields['bar'] = 'BAR"
  </code></pre>
  
  <p>instead of</p>
  
  <pre><code>f.bar = 'BAR'
  </code></pre>
  
  <p>I've tried setattr but it doesn't persist the value in the database. I also tried going through _meta.fields but got various errors along the way.</p>