title: Django : UnicodeDecodeError at /accounts/ProfileDetails/ 'utf8' codec can't decode byte 0xe1 in position 5915: invalid continuation byte
body: <p>I got this error while am adding javascript code in html page</p>
  
  <p>UnicodeDecodeError at /accounts/ProfileDetails/</p>
  
  <p>'utf8' codec can't decode byte 0xe1 in position 5915: invalid continuation byte</p>
  
  <p>Someone give idea</p>
  
  <pre><code>Traceback:
  </code></pre>
  
  <p>{% extends "base.html" %}
      File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py" in get_response
      111.                           response = callback(request, *callback_args, **callback_kwargs)</p>
  
  <pre><code>File "/usr/local/lib/python2.7/dist-packages/django/contrib/auth/decorators.py" in _wrapped_view
  20.                 return view_func(request, *args, **kwargs)
  
  File "/var/www/userreg/registration/views.py" in newpost
  275.             return render_to_response('registration/personal_information.html',context_instance=RequestContext(request))
  
  File "/usr/local/lib/python2.7/dist-packages/django/shortcuts/__init__.py" in render_to_response
  20.     return HttpResponse(loader.render_to_string(*args, **kwargs), **httpresponse_kwargs)
  
  File "/usr/local/lib/python2.7/dist-packages/django/template/loader.py" in render_to_string
  169.         t = get_template(template_name)
  
  File "/usr/local/lib/python2.7/dist-packages/django/template/loader.py" in get_template
  145.     template, origin = find_template(template_name)
  
  File "/usr/local/lib/python2.7/dist-packages/django/template/loader.py" in find_template
  134.             source, display_name = loader(name, dirs)
  
  File "/usr/local/lib/python2.7/dist-packages/django/template/loader.py" in __call__
  42.         return self.load_template(template_name, template_dirs)
  
  File "/usr/local/lib/python2.7/dist-packages/django/template/loader.py" in load_template
  45.         source, display_name = self.load_template_source(template_name, template_dirs)
  
  File "/usr/local/lib/python2.7/dist-packages/django/template/loaders/filesystem.py" in load_template_source
  39.                     return (file.read().decode(settings.FILE_CHARSET), filepath)
  
  File "/usr/lib/python2.7/encodings/utf_8.py" in decode
  16.     return codecs.utf_8_decode(input, errors, True)
  
  Exception Type: UnicodeDecodeError at /accounts/ProfileDetails/
  Exception Value: 'utf8' codec can't decode byte 0xe1 in position 5915: invalid continuation byte
  
  
  base.html
  
  &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
  &lt;html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"&gt;
  &lt;head&gt;
       &lt;meta charset="utf-8" /&gt;
       &lt;title&gt;{% block title %}Tagging Exploration{% endblock %}&lt;/title&gt;
  
       &lt;style type="text/css"&gt;
  
       .login_tabel tr td label
        {
        color:#2E6CB8;
        font-size: 13px;
        }
      &lt;/style&gt;
  
  &lt;/head&gt;
  
  &lt;body&gt;
  &lt;div id="website" style="border:1px solid #D910BB; width:1200px; margin:auto; padding:0px;"&gt;
  {% block content %}
  
  &lt;div id="nav" style="margin-top:10px; border:1px solid #0FA31E;"&gt;
  {% block navigation %}
  
  {% endblock %}
  &lt;/div&gt;
  
  &lt;div id="content" style="border:1px solid #E91135;"&gt;
  {% block main_content %}
  
  {% endblock %}
  &lt;/div&gt;
  
  {% endblock %}
  
   &lt;/div&gt;  
  
   &lt;/body&gt;
   &lt;/html&gt;
  
  
  persional_information.html
  
  {% extends "base.html" %}
  &lt;script type="text/javascript"&gt;
  
  var states = new Array();
  states['Canada'] = new Array('Alberta','British Columbia','Ontario');
  states['Mexico'] = new Array('Baja California','Chihuahua','Jalisco');
  states['United States'] = new Array('California','Florida','New York');
  
  var cities = new Array();
  cities['Canada'] = new Array();
  cities['Canada']['Alberta']          = new Array('Edmonton','Calgary');
  cities['Canada']['British Columbia'] = new Array('Victoria','Vancouver');
  cities['Canada']['Ontario']          = new Array('Toronto','Hamilton');
  cities['Mexico'] = new Array();
  cities['Mexico']['Baja California'] = new Array('Tijauna','Mexicali');
  cities['Mexico']['Chihuahua']       = new Array('Ciudad Juárez','Chihuahua');
  cities['Mexico']['Jalisco']         = new Array('Guadalajara','Chapala');
  cities['United States'] = new Array();
  cities['United States']['California'] = new Array('Los Angeles','San Francisco');
  cities['United States']['Florida']    = new Array('Miami','Orlando');
  cities['United States']['New York']   = new Array('Buffalo','new York');
  
  function setStates() {
  cntrySel = document.getElementById('country');
  stateList = states[cntrySel.value];
  changeSelect('state', stateList, stateList);
  setCities();
  }
  function setCities() {
  cntrySel = document.getElementById('country');
  stateSel = document.getElementById('state');
  cityList = cities[cntrySel.value][stateSel.value];
  changeSelect('city', cityList, cityList);
  }
  function changeSelect(fieldID, newOptions, newValues) {
  selectField = document.getElementById(fieldID);
  selectField.options.length = 0;
  for (i=0; i&lt;newOptions.length; i++) {
  selectField.options[selectField.length] = new Option(newOptions[i], newValues[i]);
  }
  }
  
  function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
  window.onload = func;
  } else {
   window.onload = function() {
    if (oldonload) {
      oldonload();
    }
    func();
  }
  }
  }
  
  addLoadEvent(function() {
  setStates();
  });
  &lt;/script&gt;
  
  &lt;form action="." method="post" enctype="multipart/form-data"&gt;{% csrf_token %}
  &lt;table border="0" align="center" cellsapcing="1" cellspadding="1"&gt;
  &lt;tr&gt;
      &lt;td colspan="2"&gt;&lt;h3&gt; Personal Information&lt;/h3&gt;&lt;/td&gt;
  &lt;/tr&gt;
  
  &lt;tr&gt;
      &lt;td colspan="2"&gt;&lt;input type="hidden" value="{{ user.id }}" name="user_id"   /&gt;      &lt;/td&gt;
  &lt;/tr&gt;
  
  &lt;tr&gt;
      &lt;td&gt;First Name&lt;/td&gt;
      &lt;td&gt;&lt;input type="text" name="fname" /&gt;&lt;/td&gt;
  &lt;/tr&gt;
  
  &lt;tr&gt;
      &lt;td&gt;Last Name &lt;/td&gt;
      &lt;td&gt;&lt;input type="text" name="lastname" /&gt;&lt;/td&gt;
  &lt;/tr&gt;
  
  &lt;tr&gt;
      &lt;td&gt;Address &lt;/td&gt;
      &lt;td&gt;&lt;input type="text" name="address1" /&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
      &lt;td&gt;&lt;/td&gt;
      &lt;td&gt;&lt;input type="text" name="address2" /&gt;&lt;/td&gt;
  &lt;/tr&gt;
  
     &lt;tr&gt;
     &lt;td style="text-align: left;"&gt;Country:&lt;/td&gt;
     &lt;td style="text-align: left;"&gt;
      &lt;select name="country" id="country" onChange="setStates();"&gt;
       &lt;option value="Canada"&gt;Canada&lt;/option&gt;
       &lt;option value="Mexico"&gt;Mexico&lt;/option&gt;
       &lt;option value="United States"&gt;United States&lt;/option&gt;
     &lt;/select&gt;
     &lt;/td&gt;
     &lt;/tr&gt;&lt;tr&gt;
     &lt;td style="text-align: left;"&gt;State:&lt;/td&gt;
     &lt;td style="text-align: left;"&gt;
        &lt;select name="state" id="state" onChange="setCities();"&gt;
           &lt;option value=""&gt;Please select a Country&lt;/option&gt;
        &lt;/select&gt;
     &lt;/td&gt;
    &lt;/tr&gt;&lt;tr&gt;
    &lt;td style="text-align: left;"&gt;City:&lt;/td&gt;
    &lt;td style="text-align: left;"&gt;
       &lt;select name="city"  id="city"&gt;
          &lt;option value=""&gt;Please select a Country&lt;/option&gt;
       &lt;/select&gt;
    &lt;/td&gt;
    &lt;/tr&gt;
    &lt;/table&gt;
    &lt;/form&gt;
  </code></pre>