- #1
shivajikobardan
- 674
- 54
- TL;DR Summary
- page not found in django, how do I fix this issue?
Goal:
127.0.0.1:8000/about
Should give:
welcome to to about us page
127.0.0.1:8000/contact
Should give:
welcome to contact page
Problem:
Both are giving "page not found at /"
This is my folder structure.
Currently, my urls.py of taskmate is:
And for todolist_app, these are my details:
Urls.py:
Views.py:
I'm suspecting that the problem is in my main project urls.py as I've not included any details about contact and about URLs there. So, I did this there.
The website runs but the goal isn't achieved.
It shows what the URLs
http://127.0.0.1:8000/task/
And
http://127.0.0.1:8000/todolist/
Show.
How do I fix this issue?
127.0.0.1:8000/about
Should give:
welcome to to about us page
127.0.0.1:8000/contact
Should give:
welcome to contact page
Problem:
Both are giving "page not found at /"
Code:
Page not found (404)
Request Method: GET
Request URL: http://127.0.0.1:8000/contact/
Using the URLconf defined in taskmate.urls, Django tried these URL patterns, in this order:
1) admin/
2) task/
3) todolist/
The current path, contact/, didn't match any of these.
You're seeing this error because you have DEBUG = True in your Django settings file. Change that to False, and Django will display a standard 404 page.
This is my folder structure.
Currently, my urls.py of taskmate is:
Python:
from django.contrib import admin
from django.urls import path, include
urlpatterns = [
path('admin/', admin.site.urls),
path('task/',include('todolist_app.urls')),
path('todolist/',include('todolist_app.urls')),
]
And for todolist_app, these are my details:
Urls.py:
Python:
from django.urls import path
from todolist_app import views
#from . import views
urlpatterns = [
path('', views.todolist),
path('contact', views.contact,name='contact'),
path('about', views.about, name="about"), #the path can be anything.
]
Views.py:
Python:
from django.shortcuts import render
from django.http import HttpResponse
# Create your views here.
def todolist(request):
context={'welcome_text':"welcome to todo list app"}
return render(request, 'html/todolist.html',context)
def contact(request):
context={'welcome_text':"welcome to contact page"}
return render(request, 'html/contact.html',context)
def about(request):
context={'welcome_text':"welcome to to about us page"}
return render(request, 'html/about.html',context)
Python:
from django.contrib import admin
from django.urls import path, include
urlpatterns = [
path('admin/', admin.site.urls),
path('task/',include('todolist_app.urls')),
path('todolist/',include('todolist_app.urls')),
path('about/',include('todolist_app.urls')),
]
The website runs but the goal isn't achieved.
It shows what the URLs
http://127.0.0.1:8000/task/
And
http://127.0.0.1:8000/todolist/
Show.
How do I fix this issue?
Last edited: