Opened 3 years ago
Closed 3 years ago
#33376 closed Cleanup/optimization (duplicate)
django.contrib.auth.urls don't function when enclosed within an application namespace.
Reported by: | Yash Pathak | Owned by: | Yash Pathak |
---|---|---|---|
Component: | contrib.auth | Version: | 4.0 |
Severity: | Normal | Keywords: | success_url |
Cc: | Yash Pathak | Triage Stage: | Unreviewed |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
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.
Change History (5)
comment:1 by , 3 years ago
Resolution: | → duplicate |
---|---|
Status: | assigned → closed |
Type: | Cleanup/optimization → New feature |
comment:2 by , 3 years ago
Has patch: | set |
---|---|
Type: | New feature → Cleanup/optimization |
comment:3 by , 3 years ago
Resolution: | duplicate |
---|---|
Status: | closed → new |
comment:4 by , 3 years ago
Cc: | added |
---|
comment:5 by , 3 years ago
Resolution: | → duplicate |
---|---|
Status: | new → closed |
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.
Duplicate of #32349.