#31724: django.urls.resolve ignores the FORCE_SCRIPT_NAME setting
-----------------------------------------+------------------------
               Reporter:  Pēteris Caune  |          Owner:  nobody
                   Type:  Uncategorized  |         Status:  new
              Component:  Core (URLs)    |        Version:  3.0
               Severity:  Normal         |       Keywords:
           Triage Stage:  Unreviewed     |      Has patch:  0
    Needs documentation:  0              |    Needs tests:  0
Patch needs improvement:  0              |  Easy pickings:  0
                  UI/UX:  0              |
-----------------------------------------+------------------------
 I suspect the `django.urls.resolve` method is not taking in account the
 FORCE_SCRIPT_NAME setting.

 First, with FORCE_SCRIPT_NAME=None, I can do the following in `manage.py
 shell`:

 {{{
 >>> from django.urls import resolve, reverse
 >>> reverse("hc-docs")
 '/docs/'
 >>> resolve(reverse("hc-docs"))
 ResolverMatch(func=hc.front.views.serve_doc, args=(), kwargs={}, url_name
 =hc-docs, app_names=[], namespaces=[], route=docs/)
 }}}

 In the above example, I can feed the result of `reverse` back into
 `resolve` and it works as expected.

 Now with FORCE_SCRIPT_NAME='/foo':

 {{{
 >>> from django.urls import resolve, reverse
 >>> reverse("hc-docs")
 '/foo/docs/'
 >>> resolve(reverse("hc-docs"))
 Traceback (most recent call last):
 (...)
     raise Resolver404({'tried': tried, 'path': new_path})
 }}}

 Here, `reverse` added the "/foo" prefix to the URL, but `resolve` didn't
 seem to recognize it.

 I suspect this is a bug but not sure. How is `django.urls.resolve`
 expected to behave here?

-- 
Ticket URL: <https://code.djangoproject.com/ticket/31724>
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/049.3eee7110550dcfbe1dca6f137ea0b893%40djangoproject.com.

Reply via email to