1👍
✅
The url’s name defaults to the lowercased model name, which in this case is 'group'
for both viewsets. Thus, reverse
cannot tell the difference and returns the first match for both.
I believe passing an explicit basename to at least one of the urls should fix it:
router = routers.DefaultRouter()
(...)
router.register(r"groups", accounts_views.GroupViewSet)
router.register(r"classes/groups", classes_views.GroupViewSet, "classes_group")
(...)
👤knbk
0👍
You can’t add paths with slash in rest_framework routers. The format is this. Check also this question asking the same.
You can either use the solution given in the linked question or set the url like that:
router.register(r"classes_groups", classes_views.GroupViewSet)
- [Answer]-Using a second app in Django
- [Answer]-Django – Add another model without Popup
- [Answer]-Django save method overwritten and type object 'cursos' has no attribute 'object'
Source:stackexchange.com