Opened 5 years ago

Closed 5 years ago

Last modified 4 years ago

#15083 closed (fixed)

TemplateResponse doesn't use custom per-request URLConf

Reported by: russellm Owned by: nobody
Component: Generic views Version: 1.2
Severity: Keywords: blocker
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

via Sayane on django-dev mailing list:

There is a problem with TemplateResponse and request.urlconf. Custom urlconf is removed[1] before TemplateResponse is rendered. This means that any call to reverse() when rendering template will use default urlconf (from settings). This makes TemplateResponse useless when using custom urlconf.

[1] http://code.djangoproject.com/browser/django/trunk/django/core/handlers/base.py#L166

Change History (3)

comment:1 Changed 5 years ago by russellm

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Accepted

I suspect the fix here will be to reorganize the logic so that the TemplateResponse is rendered before the URLConf is reset.

comment:2 Changed 5 years ago by russellm

  • Resolution set to fixed
  • Status changed from new to closed

(In [15226]) Fixed #15083 -- Corrected the order of TemplateResponse middleware handling, ensuring that custom URLConfs are valid, and that ResponseMiddleware is invoked if the TemplateResponseMiddleware causes errors. Thanks to Sayane for the report.

comment:3 Changed 4 years ago by jacob

  • milestone 1.3 deleted

Milestone 1.3 deleted

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