简体   繁体   English

ModuleNotFoundError:没有名为“ django.urls”的模块在Django 1.9中不起作用

[英]ModuleNotFoundError: No module named 'django.urls' not working in Django 1.9

I'm using Django 1.9 我正在使用Django 1.9

 from django.contrib admin
 from django.conf.urls import include, url
 from slack.views import DRSWebhookTransactionView, DRSMessageView
 from django.urls import path 

 api_patterns = ([
        path('web/', DRSWebhookTransactionView.as_view()),
        path('events/', DRSMessageView.as_view()),
    ], 'api')


 urlpatterns = [
        url(r'^admin/', admin.site.urls),
        path('api/v1/', include(api_patterns)),
]

After running python manage.py runserver: 运行python manage.py runserver之后:

from django.urls import (  # noqa
ModuleNotFoundError: No module named 'django.urls'

I'm getting this error after I tried including path. 我尝试包含路径后收到此错误。 If I don't include path it's not showing the error for the 'path', it's still showing the same error. 如果我不包含路径,则不会显示“路径”的错误,但仍会显示相同的错误。 Can someone tell how can I rewrite this program? 有人可以告诉我如何重写该程序吗? and tell me what I'm doing wrong? 告诉我我在做什么错?

for django 1.9 对于Django 1.9

from django.conf.urls import url

refer this 参考这个

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM