#32349: unable to obtain auth template password_reset_done when using namespaced
urls
---------------------------------+---------------------------------------
     Reporter:  James Miller     |                    Owner:  jhabarsingh
         Type:  Bug              |                   Status:  assigned
    Component:  Template system  |                  Version:  3.1
     Severity:  Normal           |               Resolution:
     Keywords:  password_reset   |             Triage Stage:  Unreviewed
    Has patch:  0                |      Needs documentation:  0
  Needs tests:  0                |  Patch needs improvement:  0
Easy pickings:  0                |                    UI/UX:  0
---------------------------------+---------------------------------------

Comment (by James Miller):

 Basically, the reverse function at :

 
https://github.com/django/django/blob/75182a800a621b7a5b2c0a1f39a56e753b9a58ca/django/urls/base.py#L27

 which is called by reverse_lazy('password_reset_complete') in
 django.contrib.auth.views.PasswordResetConfirmView  and
 which is called by reverse_lazy('password_reset_done') in
 django.contrib.auth.views.PasswordResetView

 is not doing a decent job.  It should find the correct namespace and then
 call the namespaced view, but it (the reverse function) only examines the
 string that is passed for a colon and returns a namespace if a colon
 exists.

 *path, view = viewname.split(':')    from
 
https://github.com/django/django/blob/75182a800a621b7a5b2c0a1f39a56e753b9a58ca/django/urls/base.py#L39

 so as the auth views mentioned above only pass in a string, no namespace
 is discovered.

 I have tried both subclassing the auth views, and also passing in a
 success_url in the path function in my urls.py file, as well as a whole
 host of other tries, but nothing works.

 I can monkeypatch the django code, to include the namespace in the call to
 reverse_lazy in django.contrib.auth.views, but I would prefer to see some
 sort of code that tries a url against the different namespaces, either in
 the reverse function or in the form_valid method.   The form_valid method
 would require editing the super_class, and there is no need to edit the
 reverse function if it is working, so it would probably be better to amend
 the auth password views mentioned above, so that they set the success_url
 dynamically based upon available namespaces.

 something like :


    psuedo-code::::
 {{{
 dict = get_resolver().namespace_dict
 for ns in dict:
     try:
           does ns:success_url path return valid
           if yes let success_url = ns:success_url
    except some_exception
 }}}

 I'll take a look tomorrow.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/32349#comment:8>
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 django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/074.b9797a52daf479f1420d5a6f9ce8b8e9%40djangoproject.com.

Reply via email to