from django.urls import path
from . import views
urlpatterns = [
path('home/', views.home, name='home'),
path('about/', views.about, name='about'),
path('contact/', views.contact, name='contact'),
]
- Import the
path
function and the views
module from the Django urls
package. - Define a list named
urlpatterns
to store the URL patterns for your Django application. - Create a URL pattern for the 'home/' endpoint, linking it to the
home
function in the views
module and assigning the name 'home' to this pattern. - Create a URL pattern for the 'about/' endpoint, linking it to the
about
function in the views
module and assigning the name 'about' to this pattern. - Create a URL pattern for the 'contact/' endpoint, linking it to the
contact
function in the views
module and assigning the name 'contact' to this pattern.