Opened 13 years ago
Closed 11 years ago
#19910 closed Cleanup/optimization (fixed)
Double redirect with APPEND_SLASH and i18n_patterns
| Reported by: | Owned by: | Bas Peschier | |
|---|---|---|---|
| Component: | Core (URLs) | Version: | 1.4 |
| Severity: | Normal | Keywords: | redirect, i18n, append_slash |
| Cc: | 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
Just a thought:
Using settings.APPEND_SLASH = True in combination with i18n_patterns may lead to unnecessary redirects, like so:
Opening URL: "/some_i18n_url"
Redirect to: "/en/some_i18n_url"
Redirect to: "/en/some_i18n_url/"
It would be more efficient to combine those redirects into.
Change History (5)
comment:1 by , 13 years ago
| Triage Stage: | Unreviewed → Accepted |
|---|
comment:2 by , 13 years ago
It might be interesting to include RedirectMiddleware in the scope of this ticket as it also performs redirects that can interact with APPEND_SLASH.
comment:3 by , 11 years ago
| Has patch: | set |
|---|---|
| Owner: | changed from to |
| Status: | new → assigned |
Created a PR for the suggestions above, should we also document the parameter as part of the public API?
comment:4 by , 11 years ago
| Triage Stage: | Accepted → Ready for checkin |
|---|
Looks good, pending some cosmetic edits. I don't feel strongly that the parameter should be documented, but happy to have it if someone sees a use case for it in user code.
This might require adding a new parameter (force_append_slash) to
request.get_full_pathas the slash might have to be inserted between the path and a possible query string. ThenCommonMiddlewarecould also benefit from it.