Bug: _TemplateResponse
is still relying on request
key from context
which maybe different from request
argument to TemplateResponse
.
#2531
Labels
need confirmation
This issue needs confirmation.
Situation
request
argument toTemplateResponse
#2191 and the resulting release 0.29.0,request
required argument has been added toTemplateResponse
constructor to become a replacement for passingrequest
as key-value pair intocontext
argument.request
keyword as a variable name that coder can use in Jinja template.Reproduction
For example, one should be able to run FastAPI server:
with
templates/item.html
However, this will raise:
when
/items/whateverid
is accessed.Cause
When all arguments to
TemplateResponse
are keyword arguments,request: Request
is obtained from one of the keyword arguments:starlette/starlette/templating.py
Line 218 in 39dccd9
However, this
request: Request
is never passed to_TemplateResponse
which will still try to findrequest: Request
fromcontext
.starlette/starlette/templating.py
Line 44 in 39dccd9
request: str
instead leading to the previously mentioned error.request
key incontext
, it will setrequest
to{}
which should also be undesirable.Important
The text was updated successfully, but these errors were encountered: