#26915 closed Bug (fixed)
Template response middleware skipped for responses returned from view middleware
Reported by: | Alex Hill | Owned by: | nobody |
---|---|---|---|
Component: | HTTP handling | Version: | 1.10 |
Severity: | Release blocker | Keywords: | |
Cc: | Triage Stage: | Accepted | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
Hi,
I upgraded a project from 1.9 to 1.10rc1 to test the waters. There's a regression when returning a response object from a view middleware - Django 1.10 does not apply template response middleware to the response, or render it when required.
As well as your template response middleware being skipped, the unrendered response causes trouble when passed to a lot of response middleware which expects response.content to be set.
When you do this in Django 1.9, remaining view middleware is skipped, but template response middleware is applied and the response is rendered.
See the difference:
1.9: https://github.com/django/django/blob/stable/1.9.x/django/core/handlers/base.py#L138
1.10: https://github.com/django/django/blob/stable/1.10.x/django/core/handlers/base.py#L176
I couldn't find any reference to this in the release notes so I'm assuming it's not intentional. Restoring the break
statement and the following if response is None
block restores the old behaviour without breaking any tests.
Change History (5)
comment:1 by , 8 years ago
Severity: | Normal → Release blocker |
---|---|
Triage Stage: | Unreviewed → Accepted |
comment:2 by , 8 years ago
Has patch: | set |
---|---|
Needs tests: | set |
PR (without a test)