8π
The view_name
should typically be [route]-detail
for routers, where [route]
is the name of the model you registered the ViewSet
under.
In your case, the view_name
should be position-detail
, not just position
. You are also using routes-detail
instead of drivingroutes-detail
, which is using the long name because your model is DrivingRoute
and not Route
. You can override this by setting a base_name
(third parameter) when using register
on the router.
router = DefaultRouter()
router.register(r'car', views.CarViewSet)
router.register(r'routes', views.DrivingRouteViewSet, "routes")
router.register(r'position', views.PositionViewSet)
router.register(r'users', views.UserViewSet)
1π
You have the following views:
- car-list
- car-detail
- drivingroute-list
- drivingroute-detail
- position-list
- position-detail
- user-list
- user-detail
If we take for example the following route:
router.register(r'car', views.CarViewSet)
It means that it is accessible under http://yourapi.com/car/ for car-list and under http://yourapi.com/car/1/ for car-detail (where 1 is the id).
The view names get built out of the class name minus suffix ViewSet plus list or detail.
Change your code according to these rules and please try again.
Cheers!
- [Django]-Failing fixture load: DoesNotExist: β¦ matching query does not exist
- [Django]-Filter JSON field django with greater than, less than and a range using _contains
- [Django]-How to get logged in username in views.py in django
- [Django]-Setting number of gunicorn workers in django settings.py
- [Django]-Django search for strings containing spaces