title: Python Django getattr(): attribute name must be string
body: <p>I am using python, Django and get the following error:</p>
  
  <pre><code>getattr(): attribute name must be string
  
  location: val = getattr(obj, field)
  
          if field in headers:
              if not isinstance(field, str):
                  val = getattr(obj, field)
              else:
                  val = getattr(obj, field.LastName)
  
              if callable(val):
                  val = val()
              if type(val) == unicode:
                  val = val.encode("utf-8")
              row.append(val)
  </code></pre>
  
  <p>I have tried many variation of code but all failed.</p>