Python 当前路径imageupload没有';这些都不匹配,找不到页面Django
我是Django的新手,我正在尝试构建一个图像分类器应用程序,我刚刚尝试构建该应用程序,但我遇到了这个错误,我该如何解决它Python 当前路径imageupload没有';这些都不匹配,找不到页面Django,python,django,django-models,image-classification,Python,Django,Django Models,Image Classification,我是Django的新手,我正在尝试构建一个图像分类器应用程序,我刚刚尝试构建该应用程序,但我遇到了这个错误,我该如何解决它 Page not found (404) Request Method: GET Request URL: http://localhost:8000/imageupload Using the URLconf defined in imageclassifier.urls, Django tried these URL patterns, in this order
Page not found (404)
Request Method: GET
Request URL: http://localhost:8000/imageupload
Using the URLconf defined in imageclassifier.urls, Django tried these URL patterns, in this order:
imageupload ^$ [name='home']
admin/
The current path, imageupload, didn't match any of these.
You're seeing this error because you have DEBUG = True in your Django settings file. Change that to False, and Django will display a standard 404 page.
以下是我在应用程序中所做的所有更改:
这是imgUpload应用程序中的views.py文件
from django.shortcuts import render
# Create your views here.
def home(request):
return render(request, 'home.html')
from django.contrib import admin
from django.urls import path,include
from . import views
urlpatterns = [
path('^$', views.home, name ='home'),
]
这是imageUpload应用程序中的URL.py文件
from django.shortcuts import render
# Create your views here.
def home(request):
return render(request, 'home.html')
from django.contrib import admin
from django.urls import path,include
from . import views
urlpatterns = [
path('^$', views.home, name ='home'),
]
这是Imageclassifier文件夹中的url.py:
"""imageclassifier URL Configuration
The `urlpatterns` list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/3.1/topics/http/urls/
Examples:
Function views
1. Add an import: from my_app import views
2. Add a URL to urlpatterns: path('', views.home, name='home')
Class-based views
1. Add an import: from other_app.views import Home
2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')
Including another URLconf
1. Import the include() function: from django.urls import include, path
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
"""
from django.contrib import admin
from django.urls import path,include
urlpatterns = [
path('imageupload', include('imgUpload.urls')),
path('admin/', admin.site.urls),
]
此外,我还在templates文件夹中添加了一个home.html文件。如何修复此错误?在最新的django路径方法中,您不需要在路径中使用^$。只需将^$从路径中删除,它就可以正常工作。我应该将其保留为空吗?