Django Tutorial · Display Data

Add Main Index Page

Learn all about Add Main Index Page in this comprehensive tutorial.

5 min read intermediate
  • Our project needs a main page.
  • Then create a new view called main, that will deal with incoming requests to root of the project:
  • Now we need to make sure that the root url points to the correct view.
  • The members page is missing a link back to the main page, so let us add that in the all_members.

Main Index Page

Our project needs a main page.

The main page will be the landing page when someone visits the root folder of the project.

Now, you get an error when visiting the root folder of your project:

127.0.0.1:8000/.

Start by creating a template called main.html:

Create new View

Then create a new view called main, that will deal with incoming requests to root of the project:

The main view does the following:

  • loads the main.html template.
  • Outputs the HTML that is rendered by the template.

Add URL

Now we need to make sure that the root url points to the correct view.

Open the urls.py file and add the main view to the urlpatterns list:

Module quiz

2 questions
1

Which of the following is true about Add Main Index Page?

2

What is the most common pitfall when working with Add Main Index Page?

Answer all questions to submit.