urls.py 456 B

123456789101112131415
  1. from django.urls import include, path
  2. from rest_framework_nested import routers
  3. from .views import EmailAddressViewSet, UserViewSet
  4. router = routers.SimpleRouter()
  5. router.register(r"users", UserViewSet)
  6. users_router = routers.NestedSimpleRouter(router, r"users", lookup="user")
  7. users_router.register(r"emails", EmailAddressViewSet, basename="user-emails")
  8. urlpatterns = [
  9. path("", include(router.urls)),
  10. path("", include(users_router.urls)),
  11. ]