[Django] #22384: Deprecate Django string magic in URLs and the ability to reverse by dotted path

24 views
Skip to first unread message

Django

unread,
Apr 4, 2014, 1:52:18 PM4/4/14
to django-...@googlegroups.com
#22384: Deprecate Django string magic in URLs and the ability to reverse by dotted
path
------------------------------------------------+------------------------
Reporter: timo | Owner: timo
Type: Cleanup/optimization | Status: new
Component: Core (URLs) | Version: master
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 |
------------------------------------------------+------------------------
Now that we've deprecated `patterns()` and recommended actually importing
your views module and referencing your view functions (or classes)
directly (#22218), I think it's time to deprecate the "Django String
Magic" (as Carl termed it) that lets you use strings in `url()`, e.g.
`url('^$', 'myapp.views.myview')`. As well as reverse by dotted path, e.g.
`reverse('myapp.views.myview')`.

Marc mentioned in that ticket "Reversing by dotted path to view is just a
bad idea."

--
Ticket URL: <https://code.djangoproject.com/ticket/22384>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Apr 4, 2014, 1:52:59 PM4/4/14
to django-...@googlegroups.com
#22384: Deprecate Django string magic in URLs and the ability to reverse by dotted
path
-------------------------------------+-------------------------------------
Reporter: timo | Owner: timo
Type: | Status: new
Cleanup/optimization | Version: master
Component: Core (URLs) | Resolution:
Severity: Normal | Triage Stage:
Keywords: | Unreviewed

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by timo):

I plan to work on this, but will wait to ensure that there are no -1's to
the idea, raising it on the mailing list if necessary.

--
Ticket URL: <https://code.djangoproject.com/ticket/22384#comment:1>

Django

unread,
Apr 4, 2014, 1:54:01 PM4/4/14
to django-...@googlegroups.com
#22384: Deprecate Django string magic in URLs and the ability to reverse by dotted
path
--------------------------------------+------------------------------------

Reporter: timo | Owner: timo
Type: Cleanup/optimization | Status: new
Component: Core (URLs) | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------
Changes (by carljm):

* stage: Unreviewed => Accepted


Comment:

+1 from me.

--
Ticket URL: <https://code.djangoproject.com/ticket/22384#comment:2>

Django

unread,
Apr 4, 2014, 2:15:42 PM4/4/14
to django-...@googlegroups.com
#22384: Deprecate Django string magic in URLs and the ability to reverse by dotted
path
--------------------------------------+------------------------------------

Reporter: timo | Owner: timo
Type: Cleanup/optimization | Status: new
Component: Core (URLs) | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------

Comment (by aaugustin):

2.0 is a pretty good target for the final removal of this feature.

--
Ticket URL: <https://code.djangoproject.com/ticket/22384#comment:3>

Django

unread,
Apr 4, 2014, 4:36:25 PM4/4/14
to django-...@googlegroups.com
#22384: Deprecate Django string magic in URLs and the ability to reverse by dotted
path
--------------------------------------+------------------------------------

Reporter: timo | Owner: timo
Type: Cleanup/optimization | Status: new
Component: Core (URLs) | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------

Comment (by Gwildor):

I agree that reversing by dotted-path-to-view is "a bad idea". I would
even say it's just ridiculous, and I didn't even knew it existed.
Obviously you should just use the url name. What would actually happen
when you have two urls to the same view? Anyway, I'm all for deprecating
that feature.

On the other hand, I'm not entirely convinced about deprecating the
dotted-path-to-view in url feature. There are a lot of settings and other
things in Django which work that way, and it's a nice feature which
prevents the imports from cluttering for the people who are still pro
FBV's. Unless it opens up the possibility of removing the necessity of
calling `as_view()` on every CBV in the urls. If deprecating this feature
is part of a bigger plan to migrate to cleaner urls for CBV's, then I'm
all for it.

--
Ticket URL: <https://code.djangoproject.com/ticket/22384#comment:4>

Django

unread,
Apr 22, 2014, 8:52:14 PM4/22/14
to django-...@googlegroups.com
#22384: Deprecate Django string magic in URLs and the ability to reverse by dotted
path
--------------------------------------+------------------------------------

Reporter: timo | Owner: timo
Type: Cleanup/optimization | Status: new
Component: Core (URLs) | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------

Comment (by marfire):

+1 from me. Are there any use cases where someone needs the string version
in `urls.py` to avoid a circular imports problem? Not that I can think of,
but I thought I'd mention it...

--
Ticket URL: <https://code.djangoproject.com/ticket/22384#comment:5>

Django

unread,
May 19, 2014, 8:59:55 AM5/19/14
to django-...@googlegroups.com
#22384: Deprecate Django string magic in URLs and the ability to reverse by dotted
path
--------------------------------------+------------------------------------

Reporter: timo | Owner: timo
Type: Cleanup/optimization | Status: new
Component: Core (URLs) | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------

Comment (by FunkyBob):

Gwildor, the feature pre-dates named url patterns [yes, there wasn't
always that feature].

Also, as I'm sure Alex will point out, it can make debugging harder, as
the error of a wrong import won't always show up, and will appear to come
from the wrong place when it does fire off.

This will have no impact on needing to call as_view on CBV. The as_view
method is a view function factory -- it is what makes the actual view
function used to invoke the CBV... you can't do without it.

--
Ticket URL: <https://code.djangoproject.com/ticket/22384#comment:6>

Django

unread,
Jun 2, 2014, 6:26:57 PM6/2/14
to django-...@googlegroups.com
#22384: Deprecate the ability to reverse by dotted path
--------------------------------------+------------------------------------

Reporter: timo | Owner: timo
Type: Cleanup/optimization | Status: new
Component: Core (URLs) | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------
Changes (by timo):

* has_patch: 0 => 1


Comment:

I've reduced the scope of this ticket to only deprecating the ability to
reverse by dotted path (instead of also removing the "string magic" in
`url()`). I'll save that bit for a future ticket.

[https://github.com/django/django/pull/2754 Pull request] is up for
review.

--
Ticket URL: <https://code.djangoproject.com/ticket/22384#comment:7>

Django

unread,
Jun 2, 2014, 10:11:35 PM6/2/14
to django-...@googlegroups.com
#22384: Deprecate the ability to reverse by dotted path
-------------------------------------+-------------------------------------
Reporter: timo | Owner: timo

Type: | Status: new
Cleanup/optimization | Version: master
Component: Core (URLs) | Resolution:
Severity: Normal | Triage Stage: Ready for
Keywords: | checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by charettes):

* stage: Accepted => Ready for checkin


Comment:

I left some comments on the PR. Except the doc issue it looks RFC.

--
Ticket URL: <https://code.djangoproject.com/ticket/22384#comment:8>

Django

unread,
Jun 3, 2014, 7:31:03 AM6/3/14
to django-...@googlegroups.com
#22384: Deprecate the ability to reverse by dotted path
-------------------------------------+-------------------------------------
Reporter: timo | Owner: timo
Type: | Status: closed
Cleanup/optimization | Version: master
Component: Core (URLs) | Resolution: fixed

Severity: Normal | Triage Stage: Ready for
Keywords: | checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Tim Graham <timograham@…>):

* status: new => closed
* resolution: => fixed


Comment:

In [changeset:"4445d36d471aae81086ed785536687a92e5aaa6d"]:
{{{
#!CommitTicketReference repository=""
revision="4445d36d471aae81086ed785536687a92e5aaa6d"
Fixed #22384 -- Deprecated reversing URLs by dotted path.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/22384#comment:9>

Django

unread,
Jun 7, 2014, 7:36:56 PM6/7/14
to django-...@googlegroups.com
#22384: Deprecate the ability to reverse by dotted path
-------------------------------------+-------------------------------------
Reporter: timo | Owner: timo

Type: | Status: closed
Cleanup/optimization | Version: master
Component: Core (URLs) | Resolution: fixed
Severity: Normal | Triage Stage: Ready for
Keywords: | checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Tim Graham <timograham@…>):

In [changeset:"250e2b422b4da93f38cd61319b9b3c9f422e6ede"]:
{{{
#!CommitTicketReference repository=""
revision="250e2b422b4da93f38cd61319b9b3c9f422e6ede"
Silenced some GIS deprecation warnings; refs #22384.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/22384#comment:10>

Django

unread,
Sep 26, 2014, 1:45:17 PM9/26/14
to django-...@googlegroups.com
#22384: Deprecate the ability to reverse by dotted path
-------------------------------------+-------------------------------------
Reporter: timo | Owner: timo

Type: | Status: closed
Cleanup/optimization | Version: master
Component: Core (URLs) | Resolution: fixed
Severity: Normal | Triage Stage: Ready for
Keywords: | checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Loic Bistuer <loic.bistuer@…>):

In [changeset:"45840927d3516770be2654422e752357d5c063a5"]:
{{{
#!CommitTicketReference repository=""
revision="45840927d3516770be2654422e752357d5c063a5"
Silenced some deprecation warnings in contrib.sitemaps; refs #22384.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/22384#comment:11>

Django

unread,
Sep 23, 2015, 7:54:47 PM9/23/15
to django-...@googlegroups.com
#22384: Deprecate the ability to reverse by dotted path
-------------------------------------+-------------------------------------
Reporter: timo | Owner: timo
Type: | Status: closed
Cleanup/optimization |

Component: Core (URLs) | Version: master
Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Tim Graham <timograham@…>):

In [changeset:"785cc71d5b3300e2702b0b2fc7316e58ca70b563" 785cc71]:
{{{
#!CommitTicketReference repository=""
revision="785cc71d5b3300e2702b0b2fc7316e58ca70b563"
Refs #22384 -- Removed the ability to reverse URLs by dotted path per
deprecation timeline.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/22384#comment:12>

Django

unread,
Sep 29, 2015, 2:00:19 PM9/29/15
to django-...@googlegroups.com
#22384: Deprecate the ability to reverse by dotted path
-------------------------------------+-------------------------------------
Reporter: timo | Owner: timo
Type: | Status: closed
Cleanup/optimization |

Component: Core (URLs) | Version: master
Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Tim Graham <timograham@…>):

In [changeset:"6348db378a8fef555aba30761857ef161112b499" 6348db37]:
{{{
#!CommitTicketReference repository=""
revision="6348db378a8fef555aba30761857ef161112b499"
Refs #22384 -- Removed obsolete code for the removal of reversing by
dotted path.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/22384#comment:13>

Django

unread,
Jun 20, 2016, 2:51:36 PM6/20/16
to django-...@googlegroups.com
#22384: Deprecate the ability to reverse by dotted path
-------------------------------------+-------------------------------------
Reporter: timo | Owner: timo
Type: | Status: closed
Cleanup/optimization |

Component: Core (URLs) | Version: master
Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Tim Graham <timograham@…>):

In [changeset:"4e400dcb79bc468ee1ff899312a00ed8dc3e795c" 4e400dc]:
{{{
#!CommitTicketReference repository=""
revision="4e400dcb79bc468ee1ff899312a00ed8dc3e795c"
Refs #22384 -- Readded RegexURLResolver.reverse().

It was removed in 785cc71d5b3300e2702b0b2fc7316e58ca70b563 only because
it was untested and unused in Django itself, however, some third-party
apps use it.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/22384#comment:14>

Django

unread,
Jun 20, 2016, 2:51:55 PM6/20/16
to django-...@googlegroups.com
#22384: Deprecate the ability to reverse by dotted path
-------------------------------------+-------------------------------------
Reporter: timo | Owner: timo
Type: | Status: closed
Cleanup/optimization |

Component: Core (URLs) | Version: master
Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Tim Graham <timograham@…>):

In [changeset:"8c25d8fc10f017ed3f8e7bf97eb936495135632e" 8c25d8fc]:
{{{
#!CommitTicketReference repository=""
revision="8c25d8fc10f017ed3f8e7bf97eb936495135632e"
[1.10.x] Refs #22384 -- Readded RegexURLResolver.reverse().

It was removed in 785cc71d5b3300e2702b0b2fc7316e58ca70b563 only because
it was untested and unused in Django itself, however, some third-party
apps use it.

Backport of 4e400dcb79bc468ee1ff899312a00ed8dc3e795c from master
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/22384#comment:15>

Reply all
Reply to author
Forward
0 new messages