Opened 6 years ago

Closed 6 years ago

Last modified 6 years ago

#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



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:



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 Changed 6 years ago by Florian Apolloner

Severity: NormalRelease blocker
Triage Stage: UnreviewedAccepted

comment:2 Changed 6 years ago by Tim Graham

Has patch: set
Needs tests: set

PR (without a test)

comment:3 Changed 6 years ago by Alex Hill

Needs tests: unset

Added tests to the patch.

comment:4 Changed 6 years ago by Tim Graham <timograham@…>

Resolution: fixed
Status: newclosed

In 44a6b40:

Fixed #26915 -- Fixed regression handling responses returned from view middleware.

comment:5 Changed 6 years ago by Tim Graham <timograham@…>

In d53e3c1e:

[1.10.x] Fixed #26915 -- Fixed regression handling responses returned from view middleware.

Backport of 44a6b4028033890d4a3832875c774db321182de6 from master

Note: See TracTickets for help on using tickets.
Back to Top