Reputation: 1
urls.py
from django.urls import path from.import views
urlpatterns = [
path('', views.index, name='index'),
path('about', views.about, name='about'),
path('ourwork', views.ourwork, name='ourwork'),
path('portfolio', views.portfolio, name='portfolio'),
path('blog', views.blog, name='blog'),
path('careers', views.careers, name='careers'),
path('contact', views.contact, name='contact'),
]
views.py
from django.shortcuts import render
# Create your views here.
def index(request):
return render(request,'artsoft/index.html')
def about(request):
return render(request,'artsoft/about.html')
def ourwork(request):
return render(request,'artsoft/ourwork.html')
def portfolio(request):
return render(request,'artsoft/portfolio.html')
def blog(request):
return render(request,'artsoft/blog.html')
def careers(request):
return render(request,'artsoft/careers.html')
def contact(request):
return render(request,'artsoft/contact.html') `
screen shot
but when i clicking on blog this is work
Upvotes: 0
Views: 147
Reputation: 3378
That because you /about/
has a slash at the end but /blog
didn't. You could go with this:
path('', views.index, name='index'),
path('about/', views.about, name='about'),
path('ourwork/', views.ourwork, name='ourwork'),
path('portfolio/', views.portfolio, name='portfolio'),
path('blog/', views.blog, name='blog'),
path('careers/', views.careers, name='careers'),
path('contact/', views.contact, name='contact'),
and by default, Django has APPEND_SLASH=True
, with this setting Django will add a slash at the end of your url so domain.com/blog
and other paths which have no slash at the end also work as normal
Upvotes: 2
Reputation: 780
As I can see where it worked (blog), you didn't add the last one /
One solution is
from django.urls import path from.import views
urlpatterns = [
path('/', views.index, name='index'),
path('about/', views.about, name='about'),
path('ourwork/', views.ourwork, name='ourwork'),
path('portfolio/', views.portfolio, name='portfolio'),
path('blog/', views.blog, name='blog'),
path('careers/', views.careers, name='careers'),
path('contact/', views.contact, name='contact'),
]
Or in the navigator put
127.0.0.1:8000/blog
127.0.0.1:8000/contact
127.0.0.1:8000/about
without the last /
Upvotes: 0