I am building a webpage from a custom bootstrap template available freely in GitHub. I have tried to connect Django to the back end. I am facing problem using urls and views. I have mentioned perfectly but i am getting page not found.
urls.py file
from django.urls import path, include
from django.conf.urls.static import static
from . import views
urlpatterns = [
path('', views.homepage, name='homepage'),
path('publications', views.publications, name='publications'),
path('alumni', views.alumni, name='alumni'),
path('contact', views.contact, name='contact'),
path('joinus', views.joinus, name='joinus'),
path('phdstudents', views.phdstudents, name='phdstudents'),
path('pi', views.pi, name='pi'),
path('project1', views.project1, name='project1'),
path('research', views.research, name='research'),
path('researchers',views.researchers, name='researchers'),
path('shiladit', views.shiladit, name='shiladit'),
path('students', views.students, name='students'),
path('team', views.students, name='team'),
]
views.py
from django.shortcuts import render
def homepage(request):
return render(request, 'lab/index.html')
def publications(request):
return render(request, 'lab/publications.html')
def alumni(request):
return render(request, 'lab/alumni.html')
def contact(request):
return render(request, 'lab/contact.html')
def joinus(request):
return render(request, 'joinus.html')
def phdstudents(request):
return render(request, 'phd_students.html')
def pi(request):
return render(request, 'lab/pi.html')
def project1(request):
return render(request, 'lab/project1.html')
def publications(request):
return render(request, 'lab/publications.html')
def research(request):
return render(request, 'lab/research.html')
def researchers(request):
return render(request, 'researchers.html')
when i click on the navbar to redirect the page i am getting error. but when i give the url it is loading how to rectify this.
CodePudding user response:
- Remove : http://127.0.01:8000/research.html
- Try This : http://127.0.01:8000/research
*In template(Html):*
- Remove
<ul>
<li><a href="research.html">Research</a></li>
</ul>
- Try This :
<ul>
<li><a href="/research/">Research</a></li>
</ul>