Code

Opened 4 years ago

Closed 4 years ago

#14228 closed (fixed)

APPEND_SLASH behaviour should be documented better

Reported by: ttencate@… Owned by: gabrielhurley
Component: Documentation Version: 1.2
Severity: Keywords:
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

Current docs say:

APPEND_SLASH

Default: True

Whether to append trailing slashes to URLs. This is only used if
CommonMiddleware is installed (see Middleware). See also PREPEND_WWW.

This is not the complete story: a slash is appended only if the URL without slash does not match any in the urlconf. This becomes an issue if the urlconf has patterns that are subsets of other patterns, like this:

urlpatterns = patterns('',
    (r'^blog/', 'blog.views.index'),
    (r'^(?P<pagename>\w+)/', 'pages.views.page'),

Even though pages.views.page does not know a page named blog, and would thus return a 404, APPEND_SLASHES will recognize /blog as a valid URL and not append the slash. I realize that this cannot be solved without actually running the view (which we don't want to do), but this behaviour should be documented.

A note about the fact that a HTTP redirect happens (and thus a round trip to the client) would also be nice.

Suggested wording:

APPEND_SLASH

Default: True

Whether to append trailing slashes to URLs. If an URL does not match
any of the patterns in the URLconf, and it doesn't end in a slash, a
HTTP redirect is issued to the same URL with the slash appended.
(Note that data in a POST request will be lost, which might not be
what you want.) The APPEND_SLASH setting is only used if
CommonMiddleware is installed (see Middleware). See also PREPEND_WWW.

Attachments (0)

Change History (2)

comment:1 Changed 4 years ago by gabrielhurley

  • Needs documentation unset
  • Needs tests unset
  • Owner changed from nobody to gabrielhurley
  • Patch needs improvement unset
  • Status changed from new to assigned
  • Triage Stage changed from Unreviewed to Accepted

comment:2 Changed 4 years ago by gabrielhurley

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

(In [14110]) Fixed #14228 -- Added additional information on what the APPEND_SLASH setting does. Thanks to ttencate for the report and draft text.

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.