Opened 5 years ago

Closed 4 years ago

#16444 closed Bug (duplicate)

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

Reported by: Jakub Roztočil 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 5 years ago by Aymeric Augustin

Needs documentation: unset
Needs tests: unset
Patch needs improvement: unset
Triage Stage: UnreviewedAccepted

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 4 years ago by Aymeric Augustin

Resolution: duplicate
Status: newclosed

Duplicate of #19541 which contains more information.

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