0

i have been trying to run this code but it doesn't show the "Hey, Welcome" in the views.py

myproject/myapp/views.py:

from django.shortcuts import render
from django.http import HttpResponse

def index(request):
    return HttpResponse("<h1>Hey, Welcome</h1>")

myproject/myapp/urls.py:

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

myproject/urls.py:

urlpatterns = [
    path('admin/', admin.site.urls),<br>
    path(' ', include('myapp.urls') ),
]

pls can you help me figure out what I'm doing wrong, when I run the code, it only shows 'the install worked successfully! congratulation!!' without running the html code that I pass in the views.py

M B
  • 2,700
  • 2
  • 15
  • 20

2 Answers2

0

Please remove space from the url pattern.

myproject/myapp/urls.py

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

myproject/urls.py

urlpatterns=[
    path("",views.index, name="index")
    path('', include('myapp.urls') )
]
Elixir Techne
  • 1,848
  • 15
  • 20
0

You are using space in path which result in this mess Try removing those spaces

path("",views.index, name="index")
path('', include('myapp.urls')),

refer this for more clarity Spaces in URLs?

THUNDER 07
  • 521
  • 5
  • 21