3
from app_listing import views
from django.urls import path, include
from rest_framework import routers

router = routers.DefaultRouter()
router.register(r'category', views.CategoryViewSet)

urlpatterns = [
    path('api/', include('router.urls'))
]

urlpatterns += router.urls

Here is the error while trying to include router.urls ,ModuleNotFoundError: No module named 'router'.

I am using Django2.1,DRF 3.8.2 and python 3.6. Tried a lot, but couldn't find a proper solution for this. Is this still an open issue ? Please help!.

Milan
  • 434
  • 1
  • 4
  • 9

1 Answers1

6

It should be just router.urls without quotes:

urlpatterns = [
    path('api/', include(router.urls))
]
neverwalkaloner
  • 46,181
  • 7
  • 92
  • 100
  • 1
    oh, I missed it. Thought it was the same router url issue in the previous DRF versions. Thanks. Now it Works. – Milan Sep 27 '18 at 07:07