def patch_admin():
    @monkeypatch_method(AdminSite)
    def login(self, request, extra_context=None):
        """
        Redirects to the site login page for the given HttpRequest.
        """
        if REDIRECT_FIELD_NAME in request.GET:
            url = request.GET[REDIRECT_FIELD_NAME]
        else:
            url = request.get_full_path()
        return redirect('%s?%s' % (
            resolve_url(settings.LOGIN_URL),
            urlencode({REDIRECT_FIELD_NAME: url})
        ))
dataset/ETHPy150Open Bouke/django-two-factor-auth/two_factor/admin.py/patch_admin/original