title: Python - 'ascii' codec can't encode character u'\xe9' in position 5: ordinal not in range(128)
body: <p>I'm trying to run a quick Django application that pulls data from Google AdWords and exposes the names of accounts that are managed by an agency. When doing so, I get the following error: </p>
  
  <pre><code>UnicodeEncodeError at /account-hierarchy/
  'ascii' codec can't encode character u'\xe9' in position 5: ordinal not in range(128)
  </code></pre>
  
  <p>Here's the snippet: </p>
  
  <pre><code>&lt;table class="pretty-table"&gt;
    &lt;thead&gt;
      &lt;tr&gt;
        &lt;td&gt;Customer ID&lt;/td&gt;
        &lt;td&gt;Client Name&lt;/td&gt;
        &lt;td&gt;Can Manage Clients&lt;/td&gt;
        &lt;td&gt;Account Currency&lt;/td&gt;
      &lt;/tr&gt;
    &lt;/thead&gt;
    {% for account in managed_accounts %}
      &lt;tr&gt;
        {% for field in account %}
          &lt;td&gt;{{ field }}&lt;/td&gt;
        {% endfor %}
      &lt;/tr&gt;
    {% endfor %}
  &lt;/table&gt;
  </code></pre>
  
  <p>where the call to <code>{{ field }}</code> is the problematic line. </p>
  
  <p>I have already added </p>
  
  <pre><code>&lt;meta http-equiv="content-type" content="text/html; charset=utf-8"&gt;
  </code></pre>
  
  <p>to the template I am rendering, but it still fails, so I believe the problem is not on the HTML template, but rather on the Python/Django engine. </p>
  
  <p>Any ideas how I can fix it? </p>
  
  <p>Here's the View code that renders the template: </p>
  
  <pre><code>def account_hierarchy(request):
  manager_ids = settings.MANAGER_IDS
  managed_accounts = []
  for manager_id in manager_ids:
      managed_accounts.extend(adwords_utils.getManagedAccounts(manager_id))
  return render_to_response('simple-table.html', {"managed_accounts": managed_accounts})
  </code></pre>
  
  <p><strong>UPDATED Question</strong></p>
  
  <ul>
  <li>Python Version: 2.7.6</li>
  <li>Models.py is currently empty</li>
  </ul>
  
  <p>What's also curious is that if I remove this: </p>
  
  <pre><code>{% for field in account %}
      &lt;td&gt;{{ field }}&lt;/td&gt;
    {% endfor %}
  </code></pre>
  
  <p>and I just print out the main array: </p>
  
  <pre><code>{{ managed_accounts }}
  </code></pre>
  
  <p>it works just fine. Not sure what's going on. </p>
  
  <p>Curious fact #2: As I managed to output the full array, I checked for character 'é' and I didn't find it on the final output. Not sure where it was coming from.</p>