Skip to content

Commit

Permalink
add drafts for docs #2110
Browse files Browse the repository at this point in the history
  • Loading branch information
jjjkkkjjj committed Sep 19, 2024
1 parent 6773674 commit a303572
Showing 1 changed file with 22 additions and 3 deletions.
25 changes: 22 additions & 3 deletions docs/topics/routing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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 <https://github.com/django/channels/issues/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
-----------------
Expand Down

0 comments on commit a303572

Please sign in to comment.