Search⌘ K
AI Features

Homepage View and Template

Explore how to set up the homepage view and template in Django. This lesson guides you through creating the view function, organizing templates, and rendering HTML to display your homepage content. Gain foundational skills to start building functional web pages in Django.

We'll cover the following...

Homepage view

After we create the URL for a specific page, a view for the page also needs to be created.

Add the following code in views.py in the app’s directory to create the view for the Homepage.

Python
from django.shortcuts import render
def index(request):
return render(request, 'listings/index.html')

The module in line 1 is used to call different helper functions. We use it here to call render (line 4) which helps generate a response that we can render in ...