From a30357234342e700e51f376958825ce8c0d7b9ca Mon Sep 17 00:00:00 2001 From: jjjkkkjjj Date: Thu, 19 Sep 2024 22:26:45 +0900 Subject: [PATCH] add drafts for docs #2110 --- docs/topics/routing.rst | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/docs/topics/routing.rst b/docs/topics/routing.rst index 983e7ef41..e265287da 100644 --- a/docs/topics/routing.rst +++ b/docs/topics/routing.rst @@ -103,10 +103,29 @@ would do this: stream = self.scope["url_route"]["kwargs"]["stream"] -Please note that ``URLRouter`` nesting will not work properly with -``path()`` routes if inner routers are wrapped by additional middleware. -See `Issue #1428 `__. +You can use [include](https://docs.djangoproject.com/en/5.1/ref/urls/#include) +function for nested routings. This is similar as Django's URL routing system. + +Here's an example for nested routings. When you configure the routings in parent ``routings.py``; + +.. code-block:: python + + urlpatterns = [ + path("app1/", include("src.app1.routings"), name="app1"), + ] + +and in child ``app1/routings.py``; + +.. code-block:: python + + app_name = 'app1' + + urlpatterns = [ + re_path(r"chats/(\d+)/$", test_app, name="chats"), + ] + +you can establish the connection via the path such like ``/app1/chats/5/``. ChannelNameRouter -----------------