I did not notice this earlier, but `hasattr` is not the right thing here, since it checks for attributes, not keys.

You want settings.LOGIN_REDIRECT.has_key, and if LOGIN_REDIRECT is not necessarily a `dict`, you need another exception handler.