#28947: str(path) causes TypeError when using translatable URL patterns
------------------------------------------+------------------------
Reporter: Tilmann Becker | Owner: nobody
Type: Bug | Status: new
Component: Core (URLs) | Version: 2.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 |
------------------------------------------+------------------------
Using [[https://docs.djangoproject.com/en/2.0/topics/i18n/translation
/#translating-url-patterns|translatable URL patterns]] like this
{{{
from django.utils.translation import gettext_lazy as _
p = path(_('example/'), ExampleView.as_view())
print(p)
# or
p = re_path(_(r'^example/$'), ExampleView.as_view())
print(p)
}}}
causes
{{{
TypeError: __str__ returned non-string (type __proxy__)
}}}
It should print a string representation of the URL pattern instead:
{{{
<URLPattern 'example/''>
}}}
This affects some consumers of URL patterns:
-
[[https://docs.djangoproject.com/en/2.0/ref/contrib/admin/admindocs/|django.contrib.admindocs]]
returns HTTP500 for ''admin/docs/views/''
- possibly Django REST Framework ''SchemaGenerator,'' when fixing
[[https://github.com/encode/django-rest-framework/issues/5675|this error]]
by using ''str(pattern)''
--
Ticket URL: <https://code.djangoproject.com/ticket/28947>
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 post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/049.bf191a63ec9442e15d19f7bcc0af1614%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.