Opened 7 years ago

Closed 7 years ago

Last modified 7 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, 7 years ago

Description: modified (diff)

comment:2 by Mariusz Felisiak, 7 years ago

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

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, 7 years ago

Owner: changed from nobody to Jonatas CD
Status: new → assigned

comment:4 by Jonatas CD, 7 years ago

Has patch: set

​PR created.

comment:5 by Marten Kenbeek, 7 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, 7 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@…>, 7 years ago

Resolution: → fixed
Status: assigned → closed

In 8aad3321:

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

comment:8 by Mariusz Felisiak <felisiak.mariusz@…>, 7 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