Opened 8 years ago

Closed 8 years ago

Last modified 8 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

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 Florian Apolloner, 8 years ago

Severity: NormalRelease blocker
Triage Stage: UnreviewedAccepted

comment:2 by Tim Graham, 8 years ago

Has patch: set
Needs tests: set

PR (without a test)

comment:3 by Alex Hill, 8 years ago

Needs tests: unset

Added tests to the patch.

comment:4 by Tim Graham <timograham@…>, 8 years ago

Resolution: fixed
Status: newclosed

In 44a6b40:

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

comment:5 by Tim Graham <timograham@…>, 8 years ago

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