Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to django 3.2 #423

Merged
merged 7 commits into from
Jul 14, 2022
Merged

Update to django 3.2 #423

merged 7 commits into from
Jul 14, 2022

Conversation

mik3y
Copy link
Member

@mik3y mik3y commented Jul 14, 2022

No description provided.

mik3y added 7 commits July 14, 2022 17:17
Prior url definitions installed routes with a `r".../?$"` path regex, meaning the same
view would be served regardless of trailing slash presence.

With the previous change, we use `path(..)` in most places, which provides a convenient
shorthand for declaring path parameters (`<int:id>` etc). However we can no longer
specify a regex in that shorthand.

This creates a new problem: Routes that formerly got a direct response, for example
`GET /api/events/`, now get a 404. This can break existing API clients, of which I'm
not sure how many there are, nor do I know their slash-or-not behaviors.

To get around this we install a new middleware, `PathRewriteMiddleware`, which rewrites
the internal path -- without redirecting -- when a trailing slash is found.
We only activate this for `/api/` routes since browsers will deal with 301s as needed
just fine.
@mik3y mik3y merged commit 384d588 into master Jul 14, 2022
@mik3y mik3y deleted the mikey/django3 branch July 14, 2022 18:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant