I need to create an endpoint that requires uuid as keyword argument.
With django.urls.path, I could easily do this like path(’/endpoint/<uuid:uuid>/’).
I am curious to know if there’s any equivalent or workaround with django.conf.urls.url.
Or should I use path in this case for ease?
Django.conf.urls.url is deprecated - why would you want to use it now?
Because original project codebase was all written with url everywhere, I don’t want to overhaul the entire project to replace deprecated url with path or re_path.
And I also don’t want to mix url and path if possible.
That’s why I am trying to find it out.
The equivalent with
url would be to match against the regex pattern for a UUID. The regex that the
uuid path converter is defined at django/converters.py at 5fcfe5361e5b8c9738b1ee4c1e9a6f293a7dda40 · django/django · GitHub.
In my opinion, it would probably be easier to convert to
path than to try to add the regex to an existing
I agree whole-heartedly with @mblayman here. If you continue with the pattern of only using
url, you’re creating more work to be done later when you need to replace them all with
At a minimum, I would use
path for all new entries. I would suggest changing
path in any individual file that you are making these new entries in. But I do agree there’s probably no immediate value in going through your other urls.py files to make changes if you’re not otherwise working in those areas of the code.