如何使用';路由器&x27;在django和DRF
我想在django使用路由器。但是,当我尝试导入模块并将其迁移到路由器时,出现了以下错误 ModuleNotFoundError:没有名为“路由器”的模块 我确实导入了模块,但我无法理解错误,即没有模块。你能给我一个解决办法吗?这是我的密码 url.py如何使用';路由器&x27;在django和DRF,django,django-rest-framework,Django,Django Rest Framework,我想在django使用路由器。但是,当我尝试导入模块并将其迁移到路由器时,出现了以下错误 ModuleNotFoundError:没有名为“路由器”的模块 我确实导入了模块,但我无法理解错误,即没有模块。你能给我一个解决办法吗?这是我的密码 url.py from django.contrib import admin from django.urls import path, include from rest_framework import routers from api.views i
from django.contrib import admin
from django.urls import path, include
from rest_framework import routers
from api.views import arduinoViewSet
router = routers.DefaultRouter()
router.register('arduino', arduinoViewSet)
urlpatterns = [
path('admin/', admin.site.urls),
path('', include('router.urls')),
path('auth/', include('rest_auth.urls')),
path('auth/registration/', include('rest_auth.registration.urls')),
]
您应该直接传递
router.url
,而不是作为字符串传递
path('', include(router.urls)),
你应该试试
path('', include(router.urls))
不带引号(”)