Reputation: 5452
I have the following urls.py
:
from django.urls import path, include
from rest_framework import routers
from TasksManagerApp import views
APP_NAME ='TasksManagerApp'
router = routers.DefaultRouter()
router.register(r'tasks', views.TaskViewSet)
router.register(r'task_templates', views.TaskTemplateViewSet)
router.register(r'task_lifecycle_nodes', views.TaskLifecycleNodeViewSet)
router.register(r'task_lifecycle_events', views.TaskLifecycleEventViewSet)
urlpatterns = [
path('', include(router.urls)),
]
For some reazon, DRF only recognizes one of the paths registered by the router: task_templates
. All other paths are not recognized and rise a 404 error:
Using the URLconf defined in Attractora.urls, Django tried these URL patterns, in this order:
es/ api-token-auth/
es/ admin/
es/ api-auth/
es/ rosetta/
es/ tasks_manager/ ^task_templates/$ [name='tasktemplate-list']
es/ tasks_manager/ ^task_templates\.(?P<format>[a-z0-9]+)/?$ [name='tasktemplate-list']
es/ tasks_manager/ ^task_templates/(?P<pk>[^/.]+)/$ [name='tasktemplate-detail']
es/ tasks_manager/ ^task_templates/(?P<pk>[^/.]+)\.(?P<format>[a-z0-9]+)/?$ [name='tasktemplate-detail']
es/ tasks_manager/ ^$ [name='api-root']
es/ tasks_manager/ ^\.(?P<format>[a-z0-9]+)/?$ [name='api-root']
^media/(?P<path>.*)$
The current path, es/tasks_manager/tasks, didn't match any of these.
I don't know why the router chose that one, it is not the first one to be registered, and all other paths are correctly registered too.
I have no idea where to look.
Upvotes: 1
Views: 812
Reputation: 5452
I found the mistake (it was a very silly one). Only TaskTemplateViewSet
was a ModelViewSet, all other where ViewSets. As soon as I fixed it, everything worked.
Upvotes: 1