Opened 6 years ago

Closed 6 years ago

Last modified 6 years ago

#30437 closed Cleanup/optimization (fixed)

Document that urlpatterns can be a sequence object.

Reported by: Batuhan Taşkaya Owned by: Jonatas CD
Component: Documentation Version: dev
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no

Description (last modified by Batuhan Taşkaya)

Why urlpatterns has to be a *Python list*? Doesn't all sequences (an object that implements collections.abc.Sequence interface) counts for that. IMO this description should change at url dispatching page. As a real example i'm using collections.UserList based pattern manager for it (can be found in here)

Change History (8)

comment:1 by Batuhan Taşkaya, 6 years ago

Description: modified (diff)

comment:2 by Mariusz Felisiak, 6 years ago

Easy pickings: set
Summary: Why urlpatterns has to be a *Python list*?Document that urlpatterns can be an iterable object.
Triage Stage: UnreviewedAccepted
Type: BugCleanup/optimization
Version: 2.2master

Agreed, we can clarify this in syntax-of-the-urlpatterns-variable, e.g. "... should be an iterable (e.g. a list or tuple) of ..."

comment:3 by Jonatas CD, 6 years ago

Owner: changed from nobody to Jonatas CD
Status: newassigned

comment:4 by Jonatas CD, 6 years ago

Has patch: set

PR created.

comment:5 by Marten Kenbeek, 6 years ago

Note that it can't be any iterable: it has to be a sequence (implement __getitem__() and __len__()) or otherwise implement __reversed__(). reversed() is called in the patterns when building the reverse url patterns.

comment:6 by Mariusz Felisiak, 6 years ago

Summary: Document that urlpatterns can be an iterable object.Document that urlpatterns can be a sequence object.

Thanks for pointing this. You're right we should be more precise.

comment:7 by Mariusz Felisiak <felisiak.mariusz@…>, 6 years ago

Resolution: fixed
Status: assignedclosed

In 8aad3321:

Fixed #30437 -- Clarified that urlpatterns can be a sequence.

comment:8 by Mariusz Felisiak <felisiak.mariusz@…>, 6 years ago

In 72fe36c2:

[2.2.x] Fixed #30437 -- Clarified that urlpatterns can be a sequence.

Backport of 8aad3321ed6f0b603361767a4fe00d046b5fdd34 from master

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