I tried to run Django for the first time and got this
Request Method: GET Request URL: http://127.0.0.1:8000/hello/new Using the URLconf defined in test.urls, Django tried these URL patterns, in this order:
hello/ [name='index'] hello/ [name='new'] admin/
The current path, hello/new, didn’t match any of these.
hello/views.py
from django.http import HttpResponse
from django.shortcuts import render
def index(request):
return HttpResponse("hello, 1")
def new(request):
return HttpResponse("hello, 2")
hello/urls.py
from django.urls import path
from . import views
urlpatterns = [
path('', views.index, name='index'),
path('', views.new, name='new')
]
urls.py in my project directory
urlpatterns = [
path('hello/', include('hello.urls')),
path('admin/', admin.site.urls)
]
You haven't defined a path matching your request, append "new" to one of the paths in your apps url config. Your paths should be unique anyway
from django.urls import path
from . import views
urlpatterns = [
path('', views.index, name='index'),
path('new/', views.new, name='new')
]