Add Main Index Page
Learn all about Add Main Index Page in this comprehensive tutorial.
- •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:
Add Link Back to Main
The members page is missing a link back to the main page, so let us add that in the all_members.html template, in the content block:
If you have followed all the steps on your own computer, you can see the result in your own browser: 127.0.0.1:8000/.
If the server is down, you have to start it again with the runserver command:
Module quiz
2 questionsWhich of the following is true about Add Main Index Page?
What is the most common pitfall when working with Add Main Index Page?
Answer all questions to submit.