Creating a home page
Creating a simple page or section in Django usually involves three steps:
- Configure a URL.
- Define a view function or class.
- Create a template.
Let’s see how to apply those steps to create a simple “home” page that will display a “welcome” message to the final user.
Configuring an URL
Django URLs (Uniform Resource Locators) are patterns used to map incoming HTTP requests to the appropriate view functions or classes that handle those requests. They define the routing mechanism for your Django project, specifying which views should be called for different URLs.
There is a main URL configuration file located at /moviesstore/urls.py
that currently has the following code:
… from django.contrib import admin from django.urls import path urlpatterns = [ path('admin/', admin.site.urls), ]
When a user types a URL (related to our Django application) in the browser...