英文:
Django can not access the url specified throwing Not found 404
问题
I'm getting Not Found: 404 error when trying to access http://127.0.0.1:8000/notes/ or http://127.0.0.1:8000/notes. My server is running and I can access the http://127.0.0.1:8000/admin but not the notes page. The app is registered in INSTALLED_APPS as well as its named Notes. I'm using Python 3.9 and Django 4.2.2
Notes\urls.py
from django.urls import path
from . import views
urlpatterns = [
path('notes/', views.notes_initiator, name='notes'),
]
Notes\views.py
from django.shortcuts import render
from django.http import HttpResponse
def notes_initiator(request):
return HttpResponse("Hello, world. You're at the notes index.")
Project\urls.py
from django.contrib import admin
from django.urls import include, path
urlpatterns = [
path('notes/', include('Notes.urls')),
path('admin/', admin.site.urls),
]
I looked at similar problems with Django Not Found errors but they don't have a solution that would work for me.
I want to see the message "Hello, world. You're at the notes index." when accessing http://127.0.0.1:8000/notes/
英文:
I'm getting Not Found: 404 error when trying to access http://127.0.0.1:8000/notes/ or http://127.0.0.1:8000/notes. My server is running and I can access the http://127.0.0.1:8000/admin but not the notes page. The app is registered in INSTALLED_APPS as well as its named Notes. Im using Python 3.9 and Django 4.2.2
Notes\urls.py
from django.urls import path
from . import views
urlpatterns = [
path('notes/', views.notes_initiator, name='notes'),
]
Notes\views.py
from django.shortcuts import render
from django.http import HttpResponse
def notes_initiator(request):
return HttpResponse("Hello, world. You're at the notes index.")
Project\urls.py
from django.contrib import admin
from django.urls import include, path
urlpatterns = [
path('notes/', include('Notes.urls')),
path('admin/', admin.site.urls),
]
I looked at similar problems with Django Not Found errors but they don't have solution that would work for me.
I want to see the message "Hello, world. You're at the notes index." when accessing http://127.0.0.1:8000/notes/
答案1
得分: 0
你能检查一下http://127.0.0.1:8000/notes/notes吗?
URL模式看起来不正确。
英文:
Hi can you check at http://127.0.0.1:8000/notes/notes.
The url pattern looks incorrect
答案2
得分: 0
要查看位于 http://127.0.0.1:8000/notes/ 的消息,请更新 Project\urls.py 中的代码。
from django.contrib import admin
from django.urls import include, path
urlpatterns = [
path('', include('Notes.urls')),
path('admin/', admin.site.urls),
]
英文:
To see the message at http://127.0.0.1:8000/notes/. Update the code in Project\urls.py
from django.contrib import admin
from django.urls import include, path
urlpatterns = [
path('', include('Notes.urls')),
path('admin/', admin.site.urls),
]
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论