Create a model

class Page():
    id: int
    name: str
    

Import to View

from .models import Page
def indexPageView(request):
        page = Page()
        page.name ="home"
        
        page1 = Page()
        page1.name = "about"

        page2 = Page()
        page2.name = "contact"

        page = [page, page1, page2]
        return render(request, "index.html", {'page': page})

Now add for loop to index.html

 {% for page in page %}
                    <h1>{{ page.name }}</h1>
 {% endfor %}
Leave a Comment