简体   繁体   English

当前路径 imageupload 与这些都不匹配,Page not Found Django

[英]The current path, imageupload, didn't match any of these, Page not Found Django

I am new to Django and I am trying to build an image classifier app, I just tried building the app but I am getting this error, how may I resolve it?我是 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:

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.

These are all changes I made in my app: This is the views.py file in imgUpload app这些都是我在我的应用程序中所做的所有更改:这是 imgUpload 应用程序中的 views.py 文件

from django.shortcuts import render

# Create your views here.
def home(request):
    return render(request, 'home.html')

This is the urls.py file in imageUpload app这是 imageUpload 应用程序中的 urls.py 文件

from django.contrib import admin
from django.urls import path,include
from . import views
urlpatterns = [
    path('^$', views.home, name ='home'),
]

And this is the urls.py in the Imageclassifier folder:这是 Imageclassifier 文件夹中的 urls.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),
        
    ]

Also, I have added a home.html file in the templates folder.另外,我在模板文件夹中添加了一个 home.html 文件。 How may I fix this error?我该如何解决这个错误?

In the latest django path methods, You do not need to use ^$ in your path.在最新的 django 路径方法中,您不需要在路径中使用 ^$。 Simply remove that ^$ from your path and it will work fine.只需从您的路径中删除 ^$ 即可正常工作。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Django 找不到页面,当前路径,与这些中的任何一个都不匹配 - Django Page not found, The current path, didn't match any of these 找不到页面 (404) - 当前路径 editEstHab/ 与其中任何一个都不匹配 - Page not found (404) - The current path, editEstHab/, didn't match any of these Python/Django“找不到页面”错误:“当前路径,...,与这些都不匹配。” - Python/Django "page not found" error: "The current path, ... , didn’t match any of these." django-当前路径…与这些都不匹配 - django - The current path … didn't match any of these django 当前路径,不匹配任何这些 - django The current path,didn't match any of these 找不到页面 (404) 当前路径,注册/POST,与其中任何一个都不匹配 - Page not found (404) The current path, register/POST, didn't match any of these 找不到页面 (404) 当前路径,注册/注册,与其中任何一个都不匹配 - Page not found (404) The current path, register/register, didn’t match any of these 找不到页面 (404) 请求方法:GET ... 当前路径,博客/博客文章,与其中任何一个都不匹配 - Page not found (404) Request Method: GET … the current path, blog/blogpost, didn't match any of these 当前路径admin与任何这些都不匹配。 詹戈 - The current path, admin, didn't match any of these. django 当前路径,注册,与 django 项目中的任何一个都不匹配 - The current path, signup, didn't match any of these in django project
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM