Home > Net >  Can't seem to make a simple Hello World app
Can't seem to make a simple Hello World app

Time:09-13

image of 404 error sorry in advance if my format is off this is my first time posting to here. I'm having a really hard time getting started with Django I've followed the tutorial on the https://djangoforbeginners.com/hello-world/ and when I finished I still get the standard landing page is there something that I'm not getting ?

 #from project.urls
from django.contrib import admin
   from django.urls import path, include  # new

 urlpatterns = [
path("admin/", admin.site.urls),
path("", include("pages.urls"))  # new
]

# from pages.urls
from django.urls import path
   from . import views

   urlpatterns = [
    path("", views.index, name="index"),
    ]

  
  #from pages.views
  from django.shortcuts import render


  from django.http import HttpResponse


  def index(request):
     return HttpResponse("<h1>Hello, World!</h1>")

CodePudding user response:

In project.urls, you have to mension app.urls, so your code must be:

 urlpatterns = [
  path("admin/", admin.site.urls),
  path("", include("app.urls"))  # new
 ]

In settings.py, just mension app as pages :

INSTALLED_APPS = [
 #defualt apps
 "pages",
]
  • Related