has_key() is deprecated in favor of key in d. But `if "redirect" in settings.LOGIN_REDIRECT:` is not enough as if LOGIN_REDIRECT is string it will pass. We could do only `if "redirect" in settings.LOGIN_REDIRECT.keys():` That is true hasattr does not test for members of a dictionary, but it works.