Included App URLs not showing in DRF browsable API

I'm using the Django Rest Framework to provide an API, which works great.

All needed URLs for routers and others too are hold in the root urls.py To better handle the growing number of routes I tried to move routes from Apps to their related app folders - as one would do with pure Django.

# urls.py
from django.contrib import admin
from django.urls import include, path
from rest_framework.routers import DefaultRouter

import core.views

router = DefaultRouter()

router.register(r'core/settings', core.views.SettingsViewSet, basename='settings')
router.register(r'core/organization', core.views.OrgViewSet, basename='org')

urlpatterns = [
    path('api/', include(router.urls)),
    path('api/een/', include('een.urls')),
    path('admin/', admin.site.urls),
    path('', include('rest_framework.urls', namespace='rest_framework')),
    path('api/tokenauth/', authviews.obtain_auth_token),
]
# een/urls.py
from django.urls import path, include
from rest_framework import routers

from . import views

app_name = 'een'
router = routers.DefaultRouter()

router.register(
    r'cvs',
    views.EENSettingsViewSet,
    basename='een-cvs',
)

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

Everything shown here is working as expected, but the included URLs are not shown in the browsable API. They are reachable and working, but they are not listed. I do use drf-spectacular, which correctly picks up even the included app urls.

I've tried several different combinations, different url order, etc - with no luck. What do I overlook? Or is this a general thing with DRF and I should really keep everything in the root urls.py - if I want the full browsable API.

Вернуться на верх