TIL/ 2020–11–10

Today I learned how to use Python on HTML.

I am currently trying to clone Airbnb. Today, I am slowly creating my home page by using Python and HTML.

There are a few things that I want to highlight:

Using for loop in HTML:

In the image above, I am in a .html file. To be able to use Python and its functions such as the for loop and if statements we need to use the symbols {% %}. In the middle of the symbols, this is where you can put in your functions.

Though, do note that using the for loop or if statements in HTML does require you to close those functions. As you see in the images above, there is an {% endfor %} and an {% endif %}. Without ending your Python code, it simply won’t work or it will generate an error that tells you to end it.

Using HTML in the Python for and if statements:

Even if you created the {% for __ in __ %} {% endfor %}, doesn’t mean that you cannot use HTML code inside it. As you can see in the images above, even if I am inside or outside the Python functions (as long as I am in the .html file) I can freely use HTML either inside or outside the Python functions.

If you are wondering about what {{pages}} or {{pages|add:-1}} means, it will be on my next blog! See you there!




Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Introduction to drag and drop in iOS 11

Not getting any drops on VeVe anymore?

How to become a Quantum Software Engineer

Era Swap Adoption

Practical Use Of SOLID Design Principles In Code

How to Add Custom Claims to JWT Tokens from an External Source in Keycloak

ErgoDEX technical update #3

How I Passed Microsoft Certification Exam 70–778: Analyzing and Visualizing Data with Microsoft…

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Renzo Regio

Renzo Regio

More from Medium

The Power of Devices and Apps

Brainpan 1

senioritis, part 4

Oysho Analysis — feb 7, 2022