[PYTHON] Loop variables at the same time in the template

Realize something like a Python zip function in a template.

python


    fist_name_list = ["Ichiro", "Hideki", "hero"]
    second_name_list = ["Suzuki", "Matsui", "Nomo"]
    temp_list = []
    for i, _ in enumerate(fist_name_list):
        temp_list.append({
            'fist_name': fist_name_list[i],
            'second_name': fist_name_list[i],
        })

    render_to_response(
        'test.html', 
        {'temp_list': temp_list,}
     )

test.html


{% for fsname in temp_list %}
    {{fsname.fist_name}}
    {{fsname.second_name}}
{% endfor %}

Recommended Posts

Loop variables at the same time in the template
Browse .loc and .iloc at the same time in pandas DataFrame
Turn multiple lists with a for statement at the same time in Python
Visualize data and understand correlation at the same time
wxPython: Draw animation and graph drawing at the same time
Steps to change table and column names in your Django model at the same time
Count the number of times two values appear in a Python 3 iterator type element at the same time
MongoDB for the first time in Python
Call the python debugger at any time
Get a datetime instance at any time of the day in Python
How to read standard input or variable files at the same time like paste command in Python
Set up a server that processes multiple connections at the same time
Plot multiple maps and data at the same time with Python's matplotlib
[Python] How to open two or more files at the same time
I want to make a music player and file music at the same time
Type conversion of multiple columns of pandas DataFrame with astype at the same time
Access files in the same directory as the executable
Learn the design pattern "Template Method" in Python
Matters examined at the study session in February
Read the output of subprocess.Popen in real time
Detect folders with the same image in ImageHash
Matters examined at the study session in May
Enter the sudo password at startup in Fabric
Specify the view URL in your Django template
At the time of python update on ubuntu
I implemented Human In The Loop ― Part ① Dashboard ―
Change the reserved words in Flask's template engine
Access the variables defined in the script from the REPL
58 The same castle
I want to replace the variables in the python template file and mass-produce it in another file.
Execute packet capture at the specified time on CentOS7
Change the time zone with Docker in Oracle Database
Register a task in cron for the first time
Output the time from the time the program was started in python
Delete 1000 objects stored in AWS S3 at a time.
Embedding in datetime when only the time is known
Select the required variables in TensorFlow and save / restore
Load the module with the same name in another location
The story around the time acquisition API in programming languages
I tried the same data analysis with kaggle notebook (python) and Power BI at the same time ②
I tried the same data analysis with kaggle notebook (python) and Power BI at the same time ①
Python built-in function ~ divmod ~ Let's get the quotient and remainder of division at the same time