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

时间:2019-03-29 12:26:21

标签: django django-rest-framework django-urls

我正在使用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)),
]

运行python manage.py runserver之后:

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

尝试包含路径后出现此错误。如果我不包含路径,则不会显示“路径”的错误,但仍会显示相同的错误。有人可以告诉我如何重写该程序吗?告诉我我在做什么错?

1 个答案:

答案 0 :(得分:3)

对于django 1.9

from django.conf.urls import url

推荐this