Opened 3 years ago

Closed 3 years ago

Last modified 7 weeks ago

#23276 closed Cleanup/optimization (fixed)

Deprecate passing views as strings to url()

Reported by: Tim Graham Owned by: Tim Graham
Component: Core (URLs) Version: master
Severity: Normal Keywords:
Cc: cmawebsite@… Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Now that we've deprecated patterns() and recommended importing your views module and referencing your view functions (or classes) directly (#22218), it's time to deprecate the "Django String Magic" that lets you use strings as views in url(), e.g. url('^$', 'myapp.views.myview'). (originally raised in #22384)

Change History (13)

comment:1 Changed 3 years ago by Tim Graham

Has patch: set

comment:2 Changed 3 years ago by Claude Paroz

Triage Stage: AcceptedReady for checkin

The patch looks good. We might see some more dependency issues with this change in some projects, but hopefully nothing unsolvable.

comment:3 Changed 3 years ago by Collin Anderson

Is it too late to back-port the docs changes to 1.7, so we stop setting bad examples earlier?

comment:4 Changed 3 years ago by Collin Anderson

Cc: cmawebsite@… added

comment:5 Changed 3 years ago by Tim Graham

On backporting the docs, every change conflicts because we also removed patterns() on master so we'd want to backport those doc changes first. I'd welcome a patch, but not sure I want to do it myself.

comment:6 Changed 3 years ago by Tim Graham <timograham@…>

Resolution: fixed
Status: newclosed

In a9fd740d22bc4fed5fdb280c036618000ee13df1:

Fixed #23276 -- Deprecated passing views as strings to url().

comment:7 Changed 3 years ago by Collin Anderson

I'm a little hesitant to remove patterns() unless we also remove it from project_template, but here is a rough backport of this change only in the docs: https://github.com/django/django/pull/3050

If we're ok with removing patterns() from project_template this late in the game (it's just for new projects, right?), I can make a patch for that too.

comment:8 Changed 3 years ago by Collin Anderson <collin@…>

In 8f9dd9f256239d77ef20d6b4d2f48f08208e504a:

[1.7.x] Refs #23276: Removed bad examples of passing views as strings to url()

partial backport of a9fd740d22 from master

comment:9 Changed 3 years ago by Tim Graham

I am okay with it.

comment:10 Changed 3 years ago by Collin Anderson <collin@…>

In e5376999fa9c75efe42ba963a00e2552f66cab9c:

Refs #23276 -- Added missing url() in some places.

comment:11 Changed 2 years ago by Tim Graham <timograham@…>

In d79122f:

Refs #23276 -- Removed passing views as strings to url() per deprecation timeline.

comment:12 Changed 7 weeks ago by Tim Graham <timograham@…>

In 90758055:

Refs #23276 -- Fixed explanation of how calling views works.

"Importing the view" is no longer applicable after
a9fd740d22bc4fed5fdb280c036618000ee13df1.

comment:13 Changed 7 weeks ago by Tim Graham <timograham@…>

In c51fdda7:

[1.11.x] Refs #23276 -- Fixed explanation of how calling views works.

"Importing the view" is no longer applicable after
a9fd740d22bc4fed5fdb280c036618000ee13df1.

Backport of 907580557053085578d8de0e1b7309e0e0ed8755 from master

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