[Django]-Adding a APIView to Django REST Framework Browsable API

25👍

Routers aren’t designed for normal views. You need use ViewSet if you want register you url to your router.

I have the same question here. Maybe you can ref it:
How can I register a single view (not a viewset) on my router?

4👍

I believe the line that includes the router.urls is ‘preempting’ other urls starting with api. Try changing,

url(r'^api/', include(router.urls)),

to

url(r'^tokenapi/', include(router.urls)),

If that works then try moving the line with include to be the last line in the url patterns list and changing tokenapi back to api.

urlpatterns = patterns('',
    url(r'^admin/', include(admin.site.urls)),
    url(r'^api/register$', RegisterUser.as_view(), name='register_user'),
    url(r'^api/auth$', ObtainAuthToken.as_view(), name='obtain_token'),
    url(r'^api/me$', ObtainProfile.as_view(), name='obtain_profile'),
    url(r'^api/recover$', FindUsername.as_view(), name='recover_username'),
    url(r'^api/', include(router.urls)),
)
👤nmgeek

Leave a comment