Opened 5 months ago

Closed 5 months ago

#35620 closed Bug (invalid)

LOGIN_REDIRECT_URL has no effect in admin

Reported by: holasoftware Owned by:
Component: contrib.admin Version: 5.1
Severity: Normal Keywords: admin, login, LOGIN_REDIRECT_URL
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by holasoftware)

In the method

    def login(self, request, extra_context=None):

of the class AdminSite, these lines have to removed:

        if (
            REDIRECT_FIELD_NAME not in request.GET
            and REDIRECT_FIELD_NAME not in request.POST
        ):
            context[REDIRECT_FIELD_NAME] = reverse("admin:index", current_app=self.name)

https://github.com/django/django/blob/main/django/contrib/admin/sites.py#L431-L435

Otherwise the setting

    LOGIN_REDIRECT_URL

has no effect.

Change History (5)

comment:1 by holasoftware, 5 months ago

Component: Uncategorizedcontrib.admin

comment:2 by holasoftware, 5 months ago

Keywords: admin login LOGIN_REDIRECT_URL added

comment:3 by holasoftware, 5 months ago

Description: modified (diff)

comment:4 by holasoftware, 5 months ago

Type: UncategorizedBug

comment:5 by Tim Graham, 5 months ago

Resolution: invalid
Status: newclosed
Summary: LOGIN_REDIRECT_URL has no effect.LOGIN_REDIRECT_URL has no effect in admin

I think it's intended behavior. While the admin login does use LoginView, the setting isn't meant to apply there. You shouldn't use the admin's login page for non-admin purposes.

Note: See TracTickets for help on using tickets.
Back to Top