Question

This is probably super simple. But I'm using WTForms and want to set the value of a field to a variable I pull from the database. But instead of displaying the dynamic variable, it's displaying the variable name.

{{ form.question.label }}
{{ form.question(value="{{ q.question }}") }}

{{ form.slug.label }}
{{ form.slug(value="{{ q.slug }}") }}

So in the field it says "{{ q.question }}" instead of something like "What is the meaning of life?".

Is there a way to display nested variables in Jinja? Or is there some other way I need to go about this? Any help is appreciated!

Was it helpful?

Solution

take out the double quotes and the template tags.

{{ form.question(value=q.question) }}

and the same for slug

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top