If the primary key is found, this code prints ‘a’ ‘b’ ‘e’. If not, only ‘a’ is printed. What can cause the exception to be swallowed?
def foo(request, e_pk):
try:
pprint('a')
facet = models.EntryFacet.objects.get(pk=e_pk)
pprint('b')
except models.EntryFacet.DoesNotExist:
pprint('c ' + sys.exc_info()[0])
except ObjectDoesNotExist:
pprint('d ' + sys.exc_info()[0])
pprint('e')
return render_to_response(...)
Environment: django 1.3, Linux. settings.py has DEBUG = True TEMPLATE_DEBUG = DEBUG
when you try
it raise TypeError: cannot concatenate ‘str’ and ‘type’ objects
so you should use:
also look at get_object_or_404