0π
β
The code you wrote is incorrect: you are working with a list, and you should use commas between the different paths, so:
from django.contrib import admin
from django.urls import path
from home import views
urlpatterns = [
path("/", views.home, name='home'), # β comma
path("about", views.about, name='about'), # β comma
path("services", views.services, name='services'), # β comma
path("about", views.contact, name='contact')
]
other problems are that you do not use a slash at the end (this is not mandatory, but is advisable). Finally two of your paths have the same name, so likely the one with about
should be contact
:
from django.contrib import admin
from django.urls import path
from home import views
urlpatterns = [
path("/", views.home, name='home'),
path("about/", views.about, name='about'),
path("services/", views.services, name='services'),
path("contact/", views.contact, name='contact')
]
1π
This is your code:-
from django.contrib import admin
from django.urls import path
from home import views
urlpatterns = [
path("/", views.home, name='home')
path("about", views.about, name='about'),
path("services", views.services, name='services')
path("about", views.contact, name='contact')
]
Your problem is you need to add (coma)" , " after all path function.
A
and You need to change Your last path "about/" to "contact/" .
This is right:-
from django.contrib import admin
from django.urls import path
from home import views
urlpatterns = [
path("/", views.home, name='home')
path("about/", views.about, name='about'),
path("services/", views.services, name='services')
path("contact/", views.contact, name='contact')
]
π€BiswajitPaloi
Source:stackexchange.com