Define URL
In the app directory (homepage), create a new file and make it urls.py. Open the file and add the following code:
from django.urls import path
from . import views
urlpatterns = [
path (‘’, views.home, name=’home’),
]
In the code above, the urlpatterns variable is a list that defines the available URL patterns in your Django project.
The path function is used to define a URL pattern. It takes three arguments. The first argument ‘ ’ is an empty string, which represents the root URL or the default URL for your application.The second argument ‘views.home’ refers to the home view function (defined in views.py) that is called when this URL pattern is matched. The third argument name=‘home’ is optional and is used to assign a name to ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access