Opened 8 months ago

Closed 8 months ago

Last modified 8 months ago

#23276 closed Cleanup/optimization (fixed)

Deprecate passing views as strings to url()

Reported by: timgraham Owned by: timgraham
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 (10)

comment:1 Changed 8 months ago by timgraham

  • Has patch set

comment:2 Changed 8 months ago by claudep

  • Triage Stage changed from Accepted to Ready 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 8 months ago by collinanderson

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

comment:4 Changed 8 months ago by collinanderson

  • Cc cmawebsite@… added

comment:5 Changed 8 months ago by timgraham

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 8 months ago by Tim Graham <timograham@…>

  • Resolution set to fixed
  • Status changed from new to closed

In a9fd740d22bc4fed5fdb280c036618000ee13df1:

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

comment:7 Changed 8 months ago by collinanderson

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 8 months 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 8 months ago by timgraham

I am okay with it.

comment:10 Changed 8 months ago by Collin Anderson <collin@…>

In e5376999fa9c75efe42ba963a00e2552f66cab9c:

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

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