[Answered ]-Converting to using URL router is causing a ImproperlyConfigured exception

1👍

Router was being passed the wrong base names (plural forms of snippet and user rather than singular). Thanks to @IainShelvington for the answer in the comments!
To elaborate:

from django.urls import path, include
from rest_framework.routers import DefaultRouter
from snippets import views

    # Create a router and register our viewsets with it.
    router = DefaultRouter()
    router.register(r'snippets', views.SnippetViewSet,basename="snippets")
    router.register(r'users', views.UserViewSet,basename="users")
    
    # The API URLs are now determined automatically by the router.
    urlpatterns = [
        path('', include(router.urls)),
    ]

should have been

from django.urls import path, include
from rest_framework.routers import DefaultRouter
from snippets import views

# Create a router and register our viewsets with it.
router = DefaultRouter()
router.register(r'snippets', views.SnippetViewSet,basename="snippet")
router.register(r'users', views.UserViewSet,basename="user")

# The API URLs are now determined automatically by the router.
urlpatterns = [
    path('', include(router.urls)),
]

Leave a comment