#28663 closed New feature (fixed)
Check for likely incorrectly migrated django.urls.path() calls (that still have regex characters in the route)
Reported by: | Chris Lamb | Owned by: | nobody |
---|---|---|---|
Component: | Core (URLs) | Version: | 2.0 |
Severity: | Normal | Keywords: | check urls |
Cc: | Triage Stage: | Accepted | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
I recently moved a project to Django 2.x, including moving to django.urls.path
. However, I wasn't careful enough in the details so ended up migrating, for example:
from django.conf.urls import url url('^faq$', views.faq, name='faq'),
to
from django.urls import path path('^faq$', views.faq, name='faq'),
This doesn't cause any errors (!) but results in, for example, reverse('faq')
returning the (encoded) url /%5Efaq$
.
As this is a) likely to be very common during the migration with a high cost of a true positive, combined with b) the fact that the chance of a false positive is fairly low, I suggest we add a check for this.
(PR incoming...)
Change History (5)
comment:1 by , 7 years ago
Has patch: | set |
---|
comment:3 by , 7 years ago
Summary: | Check for incorrectly migrated django.urls.path calls → Check for likely incorrectly migrated django.urls.path() calls (that still have regex characters in the route) |
---|---|
Triage Stage: | Unreviewed → Accepted |
Note:
See TracTickets
for help on using tickets.
PR with tests: https://github.com/django/django/pull/9183