Opened 6 years ago

Closed 6 years ago

#29218 closed Bug (invalid)

Custom URL converters break direct urls.py modules import

Reported by: Sergey Fursov Owned by: nobody
Component: Core (URLs) Version: 2.0
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Hi.

I found this problem after conversion all urls in one of my projects to modern named params.
I created custom URL Converter class and registered it in root url conf
I test my project code using py.test with enabled doctest-modules option. With this option py.test imports all modules and search docstring tests in each. Same happens with individual urls.py modules, but direct module import fails with next stacktrace:

api/urls.py:86: in <module>
    name='module',
/usr/local/lib/python3.6/site-packages/django/urls/conf.py:70: in _path
    pattern = Pattern(route, name=name, is_endpoint=True)
/usr/local/lib/python3.6/site-packages/django/urls/resolvers.py:242: in __init__
    self.converters = _route_to_regex(str(route), is_endpoint)[1]
/usr/local/lib/python3.6/site-packages/django/urls/resolvers.py:225: in _route_to_regex
    "URL route '%s' uses invalid converter %s." % (original_route, e)
E   django.core.exceptions.ImproperlyConfigured: URL route 'modules/<slug:slug>/<uid:uid>/' uses invalid converter 'uid'.

I'm not sure if this issue should be solved inside Django itself, but I thought it would be helpful to report it.

Change History (2)

comment:1 by Tim Graham, 6 years ago

The report doesn't help me understand the issue in much detail. Can you debug it a bit further so we can understand what's going on (to help decide how to proceed), or at least provide a minimal sample project so that someone else can?

comment:2 by Simon Charette, 6 years ago

Resolution: invalid
Status: newclosed

From your provided stackstrace it looks like the message points at the correct error URL route 'modules/<slug:slug>/<uid:uid>/' uses invalid converter 'uid'.

Django doesn't ship with a uid path converter, it should be uuid.

Please rely on our support channels to assert Django is actually at fault before filling such a ticket next time. Thanks!

Note: See TracTickets for help on using tickets.
Back to Top