jinja2

How to render an HTML email template with Jinja2?

How to render an HTML email template with Jinja2? Question: I want to dynamically render data in an HTML email template with Jinja2 and Python. I’m new both in Python and Jinja2. This is what I have done so far: My boilerplate dynamic /dynamic.html /script.py I have my HTML template. Just showing you the extract …

Total answers: 1

Displaying database information in HTML using Flask, Jinja2, Python and SQLAlchemy

Displaying database information in HTML using Flask, Jinja2, Python and SQLAlchemy Question: I’m trying to display information that I tried inserting into a model on my Flask HTML site. I can’t figure out how to do this because the code doesn’t seem to display anything on the page. Here’s my model: class Book(db.Model): id = …

Total answers: 2

TypeError: missing 1 required positional argument, argument is already defined

TypeError: missing 1 required positional argument, argument is already defined Question: first off if you’re reading this, thank you very much. It’s my first time posting here. I’m a bit new to Flask and Python as a whole. I’m trying to create a query to check if the user has reserved or not a class. …

Total answers: 1

How to output loop.index in jinja

How to output loop.index in jinja Question: I want to be able to output the loop.index iteration to my template , i am using ansible and i have template file.j2 and inventory file have the below group [all_servers] app01 ansible_host=10.10.1.100 app02 ansible_host=10.10.1.102 app03 ansible_host=10.10.1.103 app04 ansible_host=10.10.1.104 app05 ansible_host=10.10.1.105 app06 ansible_host=10.10.1.106 I have jinja file inside …

Total answers: 1

Can't load variables into site.css for Flask app to render home.html

Can't load variables into site.css for Flask app to render home.html Question: I’m really struggling with trying to get my site.css file to accept two variables being passed in from my app.py using Jinja2 template i.e., {{ variable }}. Within app.py, I am defining two variables called: empty_fill_line and fill_line, which dynamically update with respect …

Total answers: 1

Isolate href from previous calls inside jinja template

Isolate href from previous calls inside jinja template Question: Excuse me if this is something "stupid" or if I’m doing something wrong, but it’s the first time I ever post here and I’m actually trying to learn this thing and be clear in my questoin. First time I’m working with jinja/templates and I was trying …

Total answers: 1

django bootstrap select element one column

django bootstrap select element one column Question: i use djando and bootstrap. I use a form with a method POST and "select" option. I try to select elements belong to a table. I can see the database elements, but elements it’s not showing in a column, they showing in a row (one consecutive to another). …

Total answers: 1

Logical operators in jinja template

Logical operators in jinja template Question: Been pulling my hair out trying to use the "or" logical operator in a cloud-init jinja template. When I use: {% if distro == ‘centos’ or ‘redhat’ %} {% set group = ‘wheel’ %} cloud-init just ignores the directive. If I use separate if statements, (see below) then I …

Total answers: 1

Passing param to Airflow DAG from another DAG with TriggerDagRunOperator

Passing param to Airflow DAG from another DAG with TriggerDagRunOperator Question: I’m trying to pass a param to Airflow DAG from another DAG with TriggerDagRunOperator, here is the code: @dag(default_args=default_args, catchup=False, #schedule_interval=DAG_SCHEDULE_INTERVAL, dagrun_timeout=timedelta(seconds=3600), tags=["tag1"], doc_md=DOC_MD, max_active_runs=1) def parent_dag(date_start="", date_end=""): triggered_dag = TriggerDagRunOperator( task_id=’triggered_dag’, trigger_dag_id=’triggered_dag’, conf={"date_start": "{{date_start}}", "date_end": "{{date_start}}"} ) triggered_dag dag = parent_dag() The params …

Total answers: 1

is it possible to access JavaScript variables in Jinja?

is it possible to access JavaScript variables in Jinja? Question: How can I access javascript variables in the jinja template? Example: <script> let data_str = "video1"; let url = `{% url "renderVideo" args="${data_str}" %}` </script url: path("videoplay/<str:args>", views.videoplay, name="videoplay") Traceback: Internal Server Error: /videoplay/${data_str} I’m expecting /videoplay/video1 but it is not parsing the JavaScript variable. …

Total answers: 1