In this lesson, we’re gonna be using ‘for’ loop to show our blog’s contents. Specifically, that’s the pub_date and the body of our post.

Previous Lesson: Lesson 55: How to Show Each Blog Content in Django

In this lesson, we’re gonna be using for loop to show our blog’s contents. Specifically, that’s the pub_date and the body of our post.

Before we start, I just want to take care of the tab title here:

Can you see it?

I know that this is part of our Blog. But did you know that we can even show our blog posts’s title here? Let’s do it!

Blogs Posts for the Tab Title

The Blog tab title is located here on Line 11:

We’ll simply say this:

So that our blog post’s name will get displayed at the tab. Check it out:

Cool!

Blog Content

Now let’s take care of the blogs’s content (hence, the pub_date and the body).

pub_date

I want my pub_date to be at the center and I want it to be a little grey-colored by using the text-secondary:

Let’s see:

Nice.

body

Now let’s show the body of our blog post:

Check it out:

I think the image is too close with the body so we can do this:

That br means “break”, like having a line break. Let’s see:

Ah, that’s better.

margin

You might not see it but the body has no margins, at all. It’s simply ugly. So we can put the p tags inside a div block:

Good. You know, I just noticed that our Copyright is at the left side.

Copyright

So let’s do something about that. Simply add this on the class:

And then, we’ll have this:

Nice. Let’s commit this to GitHub:

We’re now done using for loop to show our blog’s contents. On the next lesson, we’ll take care of each and every one of our blog posts’s images.

Next Lesson: Lesson 57: Control Image Size In CSS

This article was written by Zeddrix Fabian

Zeddrix Fabian became one of Jehovah’s Witnesses on February 21, 2016, and started regular pioneering last March 2020. His goal is to be able to volunteer at Bethel. After going to both private and public school for 10 years (Grade 1 to 8 in private; Grade 9 and 10 in public school), their family tried out homeschooling when he leveled up to Grade 11 last 2019. (Continue reading on the ABOUT ZEDD menu.)

One thought on “Lesson 56: Using ‘For’ Loop to Show Our Blog’s Contents”

Leave a Reply

Your email address will not be published. Required fields are marked *