Hmmm, the use of id was just a simplification for the sake of posting. The real code is a bit more complicated and used a different variable name, but that's a good point. As far as storing the value in the exception, unfortunately, DoesNotExist is not my exception; it comes from deep within django. I'm just passing it along.