Taken from Pull Request #27. When an invalid URL is passed to impersonate, a 500 error can be raised. In most use cases, the User model's PK is an integer. Passing in an invalid integer causes a 500 error to be raised. For instance,
/impersonate/anything/that/isnt/a/digit
Just just catch the error, log the error, and raise a 404.