Replies: 1 comment 1 reply
-
|
What about middleware and request.state? This is a pattern i use often. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Use case is the following:
I have 40ish templates, all
{% extends "base.html" %}I get a function that does:
I want in all templates that x value from get_x
1st solution is to pass {"x": await_get(x)} to all templates contexts, not impossible but boring.
2nd solution would have been to use context_processor implemented recently by @alex-oleshkevich but that doesn't support async functions : it would have been elegant to just add a async processor and use
{{ x }}in base.htmlthere might be a "hackish" way to do it using the request.session, the way flashes can be implemented, but so far I failed at it
maybe the closed PR here would be a good first step, (#1701)
in any case I'm interested as to know if someone would have ideas to get that x dislayed without touching all the templates :)
Beta Was this translation helpful? Give feedback.
All reactions