#33499: {% url '...' test=a %} fails when "a" contains a forward slash
-------------------------------------------------+------------------------
Reporter: Antônio Martos Harres | Owner: nobody
Type: Uncategorized | Status: new
Component: Core (URLs) | Version: 3.2
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 |
-------------------------------------------------+------------------------
When using {% url %}, if the dictionary passed to the second parameter is
dinamically generated on the template and contains a slash, it fails with
a "No reverse match" error, to reproduce, do the following:
In the template (html file):
```{% url 'post_list' category=category %}```
In the urls.py file:
```urlpatterns = [ path('posts/<str:category>/', post_list,
name='post_list'), ]```
Now if you pass a {"category": "something/"} to the render functionality,
it will fail with a no reverse match, this is because, in the views, the
matcher for anything passed in the urls cannot contain a slash, for
instance, <str:category> will not match if it contains a slash
To solve this issue, I recommend enconding the slash as %2F
--
Ticket URL: <https://code.djangoproject.com/ticket/33499>
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/051.be9113a84bdeec9d382ce02a51bb192f%40djangoproject.com.