title: Django Try Except Not Working
body: <p>I have this code, </p>
  
  <pre><code>    try:
          print "what"
          newClassName = CourseNameAndCodeAssociation.objects.get(departmentCode__iexact =         nameAndNumberStore[0])
          print newClassName  
      except:
          print "HAHA"
  </code></pre>
  
  <p>This always prints "HAHA", despite the fact that I've run the newClassName = ... code in console and it's worked. </p>
  
  <p>Why is this happening?</p>
  
  <p><strong>EDIT</strong></p>
  
  <pre><code>def newGetAllInformation(searchTerm):
  nameAndNumberStore = modifySearchTerm(searchTerm)
  urlStore = modifyUrl(nameAndNumberStore) # need to make the change here -- why not I go to the site, check for Course name - if that is not there switch, if it is  then scrape 
  soup = getHtml(urlStore) 
  storeOfBooks = []
  storeOfBooks = scrape(soup,nameAndNumberStore)
  print nameAndNumberStore[0]
  try:
      newClassName = CourseNameAndCodeAssociation.objects.get(departmentCode__iexact = nameAndNumberStore[0])
      nameAndNumberStore = modifySearchTerm(newClassName.departmentName + " " + nameAndNumberStore[1])
      urlStore = modifyUrl(nameAndNumberStore)
      soup = getHtml(urlStore)
      storeOfBooks = scrape(soup,nameAndNumberStore)
  
  except:
      print "HAHA"
  
  return storeOfBooks
  </code></pre>
  
  <p><strong>EDIT</strong>
  After further investigation - that is, entering a valid code manually (which worked), I think that there's something up with taking the code from the array- despite the fact that both are the same data type (string).</p>
  
  <p>so <code>newClassName = CourseNameAndCodeAssociation.objects.get(departmentCode__iexact = "econ")</code> works from file, but <code>newClassName = CourseNameAndCodeAssocition.objects.get(departmentCode__iexact = nameAndNumberStore[0])</code>,where <code>nameAndNumberStore[0]</code> holds <strong>econ</strong> </p>