Django REST Framework URLs with Django 2.0 Django REST Framework URLs with Django 2.0 django django

Django REST Framework URLs with Django 2.0


urlpatterns = [    ...    path('', include(router.urls)),    path('api-auth/', include('rest_framework.urls', namespace='rest_framework')),    ...]

with path('', include(router.urls)), you can get:

http://127.0.0.1:8000/regulations/http://127.0.0.1:8000/languages/

with

path('api-auth/', include('rest_framework.urls', namespace='rest_framework')),

you can get:

http://127.0.0.1:8000/api-auth/{other paths}


After registering the router you have to include it in the urlpatterns. The way how @Ykh suggested is technically correct, but with regards to content is missing the point.

urlpatterns = [    # here you include your router    path('', include(router.urls)),    # here you include the authentication paths    path('api-auth/', include('rest_framework.urls', namespace='rest_framework')),]

Now you'll have the following routes:

http://localhost:8000/regulations/http://localhost:8000/languages/

plus:

http://localhost:8000/api-auth/{other paths}