1

I have configured a viewset inheriting viewsets.ModelViewSet in views.py. And updated the urls.py to use Routers as follows

router = DefaultRouter()
router.register(r'snippets/<int:id>', SnippetViewSet)

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

But when accessing this URL pattern it says there is no matching pattern and results in page not found.

NB: Django version : 3.1, djangorestframework version 3.12.2

Abhijith Konnayil
  • 4,067
  • 6
  • 23
  • 49

1 Answers1

1

the url pattern in router.register should be like this

router.register(r'snippets/(?P<id>[0-9]+)', SnippetViewSet)
Abhijith Konnayil
  • 4,067
  • 6
  • 23
  • 49