How to easily add one variable onto another url?
variable is 'a'
however putting {{ a }} onto another html page does not display on Flask
How to easily add one variable onto another url?
variable is 'a'
however putting {{ a }} onto another html page does not display on Flask
Could you give a bit more detail about what you're trying to do?
it's ok, I think I've got this sorted now, cheers
how did u fix it
just copied the return value onto the other app route function
I know there's a better way of doing it though, surely?
You can do something like this:
@app.context_processor
def template_context():
return {
'fortnite': 'bad',
'django': 'bad',
}
This example makes two variables ("fortnite" and "django") with the value "bad" that are automatically made available in all templates. The function is run every time a page is rendered.
thanks, I'll have a look at that later
next, I'm messing around with the module 'imageio' - any views on that?
cheers
I've not used imageio, but it looks like it's a solid library that should run fine on PythonAnywhere -- we have the minimal dependencies pre-installed.
ok, cool - and how about 'Pillow' - does that work here?
Yes. Pillow 5.2.0 is preinstalled on PythonAnywhere.
@app.context_processor def template_context(): return { 'fortnite': 'bad', 'django': 'bad', }
how to make it return a variable?
when you do this:
@app.context_processor
def template_context():
return {
'variable_name': variable_value,
}
you will be able to use variable_name
in all templates:
<p>Value of the variable is {{variable_name}}</p>
thanks, I'll give it a try