title: Type Error: expected string or bytes-like object
body: <p>I keep getting the 'expected string or bytes-like object ' error and i don't know why. Can anybody help? Thanks!</p>
  
  <p><strong>VIEW</strong></p>
  
  <pre><code>data = request.POST.get('data')
  data_an = time.strptime(request.POST['data'], "%m/%d/%y")
  newanal = Analysis(data=data_an)
  </code></pre>
  
  <p><strong>TEMPLATE</strong></p>
  
  <pre><code>&lt;tr&gt;
          &lt;td&gt;Data (DD/MM/YY)&lt;/td&gt;
          &lt;td&gt;&lt;input type="text" name="data" /&gt;&lt;/td&gt;
  &lt;/tr&gt;
  </code></pre>
  
  <p><strong>MODEL</strong></p>
  
  <pre><code>class Analysis(models.Model):
      data = models.DateField(null=True)
  </code></pre>
  
  <p>I would insert and save data from template, but when i click Save, i have 'expected string or bytes-like object'</p>
  
  <pre><code>data_an 
  time.struct_time(tm_year=2015, tm_mon=2, tm_mday=12, tm_hour=0, tm_min=0, tm_sec=0, tm_wday=3, tm_yday=43, tm_isdst=-1)
  newanal 
  data    
  '02/12/15'
  request 
  ('&lt;WSGIRequest\n'
   'path:/addanalysis/,\n'
   'GET:&lt;QueryDict: {}&gt;,\n'
   "POST:{'csrfmiddlewaretoken': '5O3kV1Z9iY6SJpIT47Dk1ITcJlWXmOt8',\n"
   " 'data': '02/12/15',\n"
  
   "COOKIES:{'csrftoken': '5O3kV1Z9iY6SJpIT47Dk1ITcJlWXmOt8',\n"
   " 'sessionid': '296m76ca2ppjkllkmqmeopgjymktl7e1'},\n"
   "META:{'AGSDESKTOPJAVA': 'C:\\\\Program Files "
   "(x86)\\\\ArcGIS\\\\Desktop10.0\\\\',\n"
   " 'ALLUSERSPROFILE': 'C:\\\\ProgramData',\n"
   " 'APPDATA': 'C:\\\\Users\\\\Asus\\\\AppData\\\\Roaming',\n"
   " 'CLASSPATH': "
   "'C:\\\\xpressmp\\\\lib\\\\xprs.jar;C:\\\\xpressmp\\\\lib\\\\xprb.jar;C:\\\\xpressmp\\\\lib\\\\xprm.jar;',\n"
   " 'COMMONPROGRAMFILES': 'C:\\\\Program Files\\\\Common Files',\n"
   " 'COMMONPROGRAMFILES(X86)': 'C:\\\\Program Files (x86)\\\\Common Files',\n"
   " 'COMMONPROGRAMW6432': 'C:\\\\Program Files\\\\Common Files',\n"
   " 'COMPUTERNAME': 'ASUS-PC',\n"
   " 'COMSPEC': 'C:\\\\WINDOWS\\\\system32\\\\cmd.exe',\n"
   " 'CONFIGSETROOT': 'C:\\\\WINDOWS\\\\ConfigSetRoot',\n"
   " 'CONTENT_LENGTH': '199',\n"
   " 'CONTENT_TYPE': 'application/x-www-form-urlencoded',\n"
   " 'CSRF_COOKIE': '5O3kV1Z9iY6SJpIT47Dk1ITcJlWXmOt8',\n"
   " 'DJANGO_SETTINGS_MODULE': 'fileconverter.settings',\n"
   " 'FPS_BROWSER_APP_PROFILE_STRING': 'Internet Explorer',\n"
   " 'FPS_BROWSER_USER_PROFILE_STRING': 'Default',\n"
   " 'FP_NO_HOST_CHECK': 'NO',\n"
   " 'GATEWAY_INTERFACE': 'CGI/1.1',\n"
   " 'HOMEDRIVE': 'C:',\n"
   " 'HOMEPATH': '\\\\Users\\\\Asus',\n"
   " 'HTTP_ACCEPT': "
   "'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8',\n"
   " 'HTTP_ACCEPT_ENCODING': 'gzip, deflate',\n"
   " 'HTTP_ACCEPT_LANGUAGE': 'it-IT,it;q=0.8,en-US;q=0.6,en;q=0.4',\n"
   " 'HTTP_CACHE_CONTROL': 'max-age=0',\n"
   " 'HTTP_CONNECTION': 'keep-alive',\n"
   " 'HTTP_COOKIE': 'sessionid=296m76ca2ppjkllkmqmeopgjymktl7e1; '\n"
   "                'csrftoken=5O3kV1Z9iY6SJpIT47Dk1ITcJlWXmOt8',\n"
   " 'HTTP_HOST': '127.0.0.1:8000',\n"
   " 'HTTP_ORIGIN': 'http://127.0.0.1:8000',\n"
   " 'HTTP_REFERER': 'http://127.0.0.1:8000/addanalisi/',\n"
   " 'HTTP_UPGRADE_INSECURE_REQUESTS': '1',\n"
   " 'HTTP_USER_AGENT': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 "
   "'\n"
   "                    '(KHTML, like Gecko) Chrome/47.0.2526.106 "
   "Safari/537.36',\n"
   " 'INCLUDE': 'C:\\\\Program Files (x86)\\\\Microsoft Visual '\n"
   "            'Studio\\\\VC98\\\\atl\\\\include;C:\\\\Program Files "
   "(x86)\\\\Microsoft '\n"
   "            'Visual Studio\\\\VC98\\\\mfc\\\\include;C:\\\\Program Files '\n"
   "            '(x86)\\\\Microsoft Visual Studio\\\\VC98\\\\include',\n"
   " 'LIB': 'C:\\\\Program Files (x86)\\\\Microsoft Visual '\n"
   "        'Studio\\\\VC98\\\\mfc\\\\lib;C:\\\\Program Files (x86)\\\\Microsoft "
   "Visual '\n"
   "        'Studio\\\\VC98\\\\lib',\n"
   " 'LOCALAPPDATA': 'C:\\\\Users\\\\Asus\\\\AppData\\\\Local',\n"
   " 'LOGONSERVER': '\\\\\\\\MicrosoftAccount',\n"
   " 'NUMBER_OF_PROCESSORS': '8',\n"
   " 'OS': 'Windows_NT',\n"
   " 'PATH': 'C:\\\\Program Files (x86)\\\\Cuminas\\\\Document Express DjVu '\n"
   '         '
   "'Plug-in\\\\;C:\\\\ProgramData\\\\Oracle\\\\Java\\\\javapath;C:\\\\Program "
   "Files '\n"
   "         '(x86)\\\\NVIDIA '\n"
   "         'Corporation\\\\PhysX\\\\Common;C:\\\\xpressmp\\\\bin;C:\\\\Program "
   "Files '\n"
   "         '(x86)\\\\Intel\\\\iCLS Client\\\\;C:\\\\Program "
   "Files\\\\Intel\\\\iCLS '\n"
   "         'Client\\\\;C:\\\\Program Files\\\\Common Files\\\\Microsoft "
   "Shared\\\\Windows '\n"
   "         'Live;C:\\\\Program Files (x86)\\\\Common Files\\\\Microsoft '\n"
   "         'Shared\\\\Windows '\n"
   '         '
   "'Live;C:\\\\WINDOWS\\\\system32;C:\\\\WINDOWS;C:\\\\WINDOWS\\\\System32\\\\Wbem;C:\\\\WINDOWS\\\\System32\\\\WindowsPowerShell\\\\v1.0\\\\;C:\\\\Program "
   "'\n"
   "         'Files (x86)\\\\Windows Live\\\\Shared;C:\\\\Program Files '\n"
   "         '(x86)\\\\Intel\\\\OpenCL SDK\\\\2.0\\\\bin\\\\x86;C:\\\\Program "
   "Fi... &lt;trimmed 7923 bytes string&gt;
  mat 
  '1'
  data_ca 
  time.struct_time(tm_year=2015, tm_mon=2, tm_mday=12, tm_hour=0, tm_min=0, tm_sec=0, tm_wday=3, tm_yday=43, tm_isdst=-1)
  </code></pre>