Skip to content

Commit a303572

Browse files
author
jjjkkkjjj
committed
add drafts for docs #2110
1 parent 6773674 commit a303572

File tree

1 file changed

+22
-3
lines changed

1 file changed

+22
-3
lines changed

docs/topics/routing.rst

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,10 +103,29 @@ would do this:
103103
104104
stream = self.scope["url_route"]["kwargs"]["stream"]
105105
106-
Please note that ``URLRouter`` nesting will not work properly with
107-
``path()`` routes if inner routers are wrapped by additional middleware.
108-
See `Issue #1428 <https://github.com/django/channels/issues/1428>`__.
109106
107+
You can use [include](https://docs.djangoproject.com/en/5.1/ref/urls/#include)
108+
function for nested routings. This is similar as Django's URL routing system.
109+
110+
Here's an example for nested routings. When you configure the routings in parent ``routings.py``;
111+
112+
.. code-block:: python
113+
114+
urlpatterns = [
115+
path("app1/", include("src.app1.routings"), name="app1"),
116+
]
117+
118+
and in child ``app1/routings.py``;
119+
120+
.. code-block:: python
121+
122+
app_name = 'app1'
123+
124+
urlpatterns = [
125+
re_path(r"chats/(\d+)/$", test_app, name="chats"),
126+
]
127+
128+
you can establish the connection via the path such like ``/app1/chats/5/``.
110129

111130
ChannelNameRouter
112131
-----------------

0 commit comments

Comments
 (0)