I'm trying to set up Django REST Framework with Django 2.0 project which means url(r'^something/' ...
has been replaced with path(something/ ...
.
I'm trying to work out how to set up my rest_framework
patterns.
This is what I have:
router = routers.DefaultRouter()
router.register(r'regulations', api.RegulationViewSet)
router.register(r'languages', api.LanguageViewSet)
urlpatterns = [
...
path('api-auth/', include('rest_framework.urls', namespace='rest_framework')),
...
]
If I go to http://127.0.0.1:8000/regulations
I simply get:
Page not found (404)
How should I set up my urlpatterns
?
with
path('', include(router.urls)),
you can get:with
you can get:
After registering the
router
you have to include it in theurlpatterns
. The way how @Ykh suggested is technically correct, but with regards to content is missing the point.Now you'll have the following routes:
plus: