#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.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/057.1773d35f758861d3abadc7cadaf433c8%40djangoproject.com.

Reply via email to