1

I want to define a path to access a certain api. What works so far (urls.py):

router = routers.DefaultRouter()
router.register(r'test', views.TestViewSet)
urlpatterns = patterns('',
    url(r'^api/', include(router.urls)),
)

What i would like to do is adding a new ViewSet which provides "subfunctionality" of test (urls.py):

router.register(r'test/add', views.TestNewViewSet)

But this does not work. When accessing this api, all i get is a "404 Not Found" error. No exceptions are thrown when accessing the api. So what is wrong?

Any help is appreciated!

rand0m
  • 903
  • 2
  • 8
  • 16

1 Answers1

4

Try with

urlpatterns = patterns('',
url(r'^api/', include(router.urls)),
url(r'^test/add/$',  TestNewViewSet.as_view(), name='whatever'),

)

arcegk
  • 1,480
  • 12
  • 15
  • Thanks! True, it is not possible to add a path with slashes when using a router. Everything after a slash is a "lookup" value and not part of the prefix: http://www.django-rest-framework.org/api-guide/routers#defaultrouter – rand0m Jul 12 '14 at 20:32