[Django] #33376: django.contrib.auth.urls don't function when enclosed within an application namespace.

12 views
Skip to first unread message

Django

unread,
Dec 17, 2021, 8:43:50 AM12/17/21
to django-...@googlegroups.com
#33376: django.contrib.auth.urls don't function when enclosed within an application
namespace.
-------------------------------------+-------------------------------------
Reporter: | Owner: Yash Pathak
FuriousBluffer |
Type: | Status: assigned
Cleanup/optimization |
Component: | Version: 4.0
contrib.auth |
Severity: Normal | Keywords: success_url
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
If you define the application namespace in a urls.py file of an app and
include the auth URLs provided by Django, they return errors associating
to Exception Type: NoReverseMatch.

{{{
from django.urls import path, include
from .apps import UsersConfig

app_name = UsersConfig.name

urlpatterns = [
path('accounts/', include("django.contrib.auth.urls")),
]
}}}

The success_url fails to redirect to the correct url since they are more
or less defined in a static manner.

By making a few changes in the auth/views.py file, this issue can be
fixed. One additional change, that needs to be done by the developer, is
to define the app name in the settings.py file separately(Just like
LOGIN_REDIRECT_URL). For Example:

{{{
LOGIN_REDIRECT_URL = 'onboarding'

LOGOUT_REDIRECT_URL = "onboarding"

AUTH_APPLICATION_NAMESPACE = 'users'
}}}
'users' is the name of my app as defined in the former code snippet.

--
Ticket URL: <https://code.djangoproject.com/ticket/33376>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Dec 17, 2021, 10:58:59 AM12/17/21
to django-...@googlegroups.com
#33376: django.contrib.auth.urls don't function when enclosed within an application
namespace.
------------------------------+---------------------------------------
Reporter: Yash Pathak | Owner: Yash Pathak
Type: New feature | Status: closed
Component: contrib.auth | Version: 4.0
Severity: Normal | Resolution: duplicate
Keywords: success_url | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
------------------------------+---------------------------------------
Changes (by Mariusz Felisiak):

* status: assigned => closed
* type: Cleanup/optimization => New feature
* resolution: => duplicate


Comment:

Duplicate of #32349.

--
Ticket URL: <https://code.djangoproject.com/ticket/33376#comment:1>

Django

unread,
Dec 17, 2021, 11:37:41 AM12/17/21
to django-...@googlegroups.com
#33376: django.contrib.auth.urls don't function when enclosed within an application
namespace.
-------------------------------------+-------------------------------------
Reporter: Yash Pathak | Owner: Yash
Type: | Pathak
Cleanup/optimization | Status: closed

Component: contrib.auth | Version: 4.0
Severity: Normal | Resolution: duplicate
Keywords: success_url | Triage Stage:
| Unreviewed
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Yash Pathak):

* has_patch: 0 => 1
* type: New feature => Cleanup/optimization


--
Ticket URL: <https://code.djangoproject.com/ticket/33376#comment:2>

Django

unread,
Dec 17, 2021, 11:48:35 AM12/17/21
to django-...@googlegroups.com
#33376: django.contrib.auth.urls don't function when enclosed within an application
namespace.
-------------------------------------+-------------------------------------
Reporter: Yash Pathak | Owner: Yash
Type: | Pathak
Cleanup/optimization | Status: new

Component: contrib.auth | Version: 4.0
Severity: Normal | Resolution:
Keywords: success_url | Triage Stage:
| Unreviewed
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Yash Pathak):

* status: closed => new
* resolution: duplicate =>


--
Ticket URL: <https://code.djangoproject.com/ticket/33376#comment:3>

Django

unread,
Dec 17, 2021, 12:16:14 PM12/17/21
to django-...@googlegroups.com
#33376: django.contrib.auth.urls don't function when enclosed within an application
namespace.
-------------------------------------+-------------------------------------
Reporter: Yash Pathak | Owner: Yash
Type: | Pathak
Cleanup/optimization | Status: new
Component: contrib.auth | Version: 4.0
Severity: Normal | Resolution:
Keywords: success_url | Triage Stage:
| Unreviewed
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Yash Pathak):

* cc: Yash Pathak (added)


--
Ticket URL: <https://code.djangoproject.com/ticket/33376#comment:4>

Django

unread,
Dec 17, 2021, 12:44:27 PM12/17/21
to django-...@googlegroups.com
#33376: django.contrib.auth.urls don't function when enclosed within an application
namespace.
-------------------------------------+-------------------------------------
Reporter: Yash Pathak | Owner: Yash
Type: | Pathak
Cleanup/optimization | Status: closed
Component: contrib.auth | Version: 4.0
Severity: Normal | Resolution: duplicate

Keywords: success_url | Triage Stage:
| Unreviewed
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

* status: new => closed
* resolution: => duplicate


Comment:

Please don't reopen closed ticket. This is a duplicate, you can add a
comment to the original ticket, however creating a new setting is always
controversial. You can raise the idea on the DevelopersMailingList to
reach a wider audience and see what other think, but I don't think there
would be consensus to add that complexity.

--
Ticket URL: <https://code.djangoproject.com/ticket/33376#comment:5>

Reply all
Reply to author
Forward
0 new messages