I’m facing an issue with Django REST Framework where a specific route is not appearing in the API list when I access https://myserver.com/api/. Here’s my setup:
url.py
from django.urls import path, include
from rest_framework.routers import DefaultRouter
from . import views
router = DefaultRouter()
router.register(r'myapi', views.myapiViewSet, basename='myapi')
urlpatterns = [
path('api/', include(router.urls)),
# Other URL patterns
]
views.py
class myapiViewSet(ViewSet):
permission_classes = (MaintenanceCheck,)
throttle_classes = [UserRateThrottle]
When I visit https://myserver.com/api/, I expect to see the myapi endpoint listed, but it doesn’t appear so when I can access https://myserver.com/api/myapi/ directly and it doesn’t work and it shows me “Not Foundn The requested resource was not found on this server.”
- The router is correctly included in the main URL conf.
- The view myapi is a proper viewset.
- The URL prefix api/ is used properly.
I can’t figure out why the myapi endpoint doesn’t show up in the API list. Any insights or suggestions would be greatly appreciated!