Book Image

Learning Website Development with Django

Book Image

Learning Website Development with Django

Overview of this book

Table of Contents (18 chapters)
Learning Website Development with Django
Credits
About the Author
About the Reviewers
Preface
Index

URLs and Views: Creating the Main Page


The first thing that comes to mind after seeing the welcome page of the development server is how can we change it? To create our own welcome page, we need to define an entry point to our application in the form of a URL, and tell Django to call a particular Python function when a visitor accesses this URL. We will write this Python function ourselves, and make it display our own welcome message.

Creating the Main Page View

A view in Django terminology is a regular Python function that responds to a page request by generating the corresponding page. To write our first Django view for the main page, we first need to create a Django application inside our project. You can think of an application as a container for views and data models. To create it, issue the following command within our django_bookmarks folder:

$ python manage.py startapp bookmarks

The syntax of application creation is very similar to that of project creation. We used startapp as the first...