Opened 7 years ago

Closed 7 years ago

Last modified 7 years ago

#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 Chris Lamb, 7 years ago

Has patch: set

comment:2 by Chris Lamb, 7 years ago

PR updated after review.

comment:3 by Tim Graham, 7 years ago

Summary: Check for incorrectly migrated django.urls.path callsCheck for likely incorrectly migrated django.urls.path() calls (that still have regex characters in the route)
Triage Stage: UnreviewedAccepted

comment:4 by Tim Graham <timograham@…>, 7 years ago

Resolution: fixed
Status: newclosed

In 998c9dd:

Fixed #28663 -- Add a check for likely incorrectly migrated django.urls.path() routes.

comment:5 by Tim Graham <timograham@…>, 7 years ago

In 518c1135:

[2.0.x] Fixed #28663 -- Add a check for likely incorrectly migrated django.urls.path() routes.

Backport of 998c9dd599cd907bb38f440fff13a808571589f8 from master

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