Opened 4 years ago

Closed 2 years ago

#16444 closed Bug (duplicate)

reverse() doesn't respect request.urlconf when called from a generator passed to a response

Reported by: jakub Owned by: nobody
Component: Core (Other) Version: 1.3
Severity: Normal Keywords: urlconf, reverse
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

When a middleware sets requests.urlconf and a view returns an HttpResponse with a generator as its content, then urls reverse()'d in the generator won't honor the URL Conf set by the middleware.

Here is a stripped-down example: https://github.com/jkbr/django-reverse-bug

(Here is the view passing a generator: https://github.com/jkbr/django-reverse-bug/blob/master/views.py)

Change History (2)

comment:1 Changed 4 years ago by aaugustin

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

The URLconf is reset here: https://code.djangoproject.com/browser/django/trunk/django/core/handlers/base.py#L173

And this line runs after the view function returns, but before the response is evaluated, so before the generator is run.

comment:2 Changed 2 years ago by aaugustin

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

Duplicate of #19541 which contains more information.

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