Home > Software design >  Page not found (404) Request Method: GET trying to click to another .html file
Page not found (404) Request Method: GET trying to click to another .html file

Time:09-30

I've done so much research I must have clearly missed something done or something wrong. The server I'm running is localhost:8000 It actually happens on all three .html files. I've added the homepage everything works fine until I try to click on another html file and recieved. Screenshot of the error message here Page not found (404) Request Method: GET trying to Using the URLconf defined in user.urls, Django tried these URL patterns, in this order:`

admin/
secret/
home/ [name='home']
home/ [name='contact']
home/ [name='Project']
^static/(?P<path>.*)$
  index/Project.html.

Here's the root urls.py:

from django.contrib import admin
from django.urls import path, include
from django.conf.urls import url
from django.conf import settings
from django.conf.urls.static import static
from django.views.generic import RedirectView
from portfolio_django import views
admin.autodiscover()

urlpatterns = [
    path('admin/', include('admin_honeypot.urls', namespace='admin_honeypot')),
    url('secret/', admin.site.urls),
    path('home/', include("portfolio_django.urls")),
]  static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)

from django.urls import path
from portfolio_django import views

urlpatterns = [
    path('', views.home, name='home'),
    path('', views.contact, name='contact'),
    path('', views.Project, name='Project')


views.py

from django.shortcuts import render


# Create your views here.
def home(request):
    return render(request, 'home.html')


def Portfolio(request):
    return render(request, 'Project.html')


def contact(request):
    return render(request, 'contact.html')

CodePudding user response:

You are receiving error 404 because you haven't defined a url pattern for http://localhost:8000

You need to change path('home/', include("portfolio_django.urls")) to path('', include("portfolio_django.urls"))

and change the following:

    path('', views.home, name='home'),
    path('contact/', views.contact, name='contact'),
    path('project/', views.Project, name='Project')
  • Related