简体   繁体   English

在Django urls.py文件中获取“空路径与这些中的任何一个都不匹配”错误

[英]Getting “The empty path didn't match any of these” error in Django urls.py file

项目结构

I am working on Django and I am getting error while run code like this : 我正在研究Django,我在运行这样的代码时遇到错误:

Using the URLconf defined in mysite.urls, Django tried these URL

patterns, in this order:  

^admin/  
^employees/  

The empty path didn't match any of these.

here is my urls.py : 这是我的urls.py:

from django.conf.urls import url
from django.contrib import admin
from webapp import views
from django.urls import path
from rest_framework.urlpatterns import format_suffix_patterns


urlpatterns = [

url(r'^admin/', admin.site.urls),
url(r'^employees/', views.employeeList.as_view()),
]

here is vies.py: 这是vies.py:

class employeeList(APIView):

def get(self, request):
    employees1 = employees.objects.all()
    serializer = employeesSerializer(employees1, many=True)

    return Response(serializer.data)

def post(self):
    pass

and Settings.py : 和Settings.py:

INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'rest_framework',
'webapp'
 ]

try changing url from 尝试更改网址

url(r'^employees/', views.employeeList.as_view())

to

url(r'^employees/$', views.employeeList.as_view(), name='employees' )

暂无
暂无

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

相关问题 Django NoReverseMatch 错误 - urls.py 路径似乎匹配 - Django NoReverseMatch error - urls.py path appears to match urls.py 有效,但是当我使用<int:id>更新特定项目然后我得到“当前路径不匹配任何这些”错误</int:id> - urls.py works but when I use <int:id> to update a particular item then I get "Current path didn't match any of these" error Django:为什么当前URL与urls.py中的任何模式都不匹配 - Django: Why Doesn't the Current URL Match any Patterns in urls.py urls.py中的Django错误 - Django error in urls.py 我在 django 中收到 No reverse match error 但它用于 urls.py - I am getting No reverse match error in django but it is used urls.py Django 尝试了这些 URL 模式:空路径与其中任何一个都不匹配 - Django tried these URL patterns: The empty path didn’t match any of these 空路径与其中任何一个都不匹配。 Django - The empty path didn’t match any of these. Django 使用 lec3.urls 中定义的 URLconf,Django 尝试了这些 URL 模式,顺序如下: admin/ hello/ 空路径与其中任何一个都不匹配 - Using the URLconf defined in lec3.urls, Django tried these URL patterns, in this order: admin/ hello/ The empty path didn't match any of these 运行 Django 服务器时出错 - 空路径与这些都不匹配 - Error while running Django Server -The empty path didn't match any of these Django-空行处的IndentationError-urls.py - Django - IndentationError at empty line - urls.py
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM