Movatterモバイル変換


[0]ホーム

URL:


Skip to content

URL Router

Overview

A Single Page Application URL router, which is a variant ofreactpy-router that uses Django conventions.

Note

Looking for more details on URL routing?

This package only contains Django specific URL routing features. Standard features can be found withinreactive-python/reactpy-router.


Django Router

URL router that enables the ability to conditionally render other components based on the client's current URLpath.

Pitfall

All pages wheredjango_router is used must have identical, or more permissive URL exposure within Django'sURL patterns. You can think of the router component as a secondary, client-side router. Django will always handle the initial load of the webpage.

You can duplicate all your URL patterns within both Django and ReactPy, but it's easiest to use a wildcard.* within Django'surlpatterns and let ReactPy handle the rest. For example...

urlpatterns=[re_path(r"^.*$",my_reactpy_router_view),]
 1 2 3 4 5 6 7 8 910111213141516171819
fromreactpyimportcomponent,htmlfromreactpy_routerimportroutefromreactpy_django.routerimportdjango_router@componentdefmy_component():returndjango_router(route("/router/",html.div("Example 1")),route("/router/any/<value>/",html.div("Example 2")),route("/router/integer/<int:value>/",html.div("Example 3")),route("/router/path/<path:value>/",html.div("Example 4")),route("/router/slug/<slug:value>/",html.div("Example 5")),route("/router/string/<str:value>/",html.div("Example 6")),route("/router/uuid/<uuid:value>/",html.div("Example 7")),route("/router/two_values/<int:value>/<str:value2>/",html.div("Example 8")),route("/router/*",html.div("Fallback")),)
See Interface

NameTypeDescriptionDefault
*routesRouteAn object fromreactpy-router containing apath,element, and child*routes.N/A

TypeDescription
VdomDict|NoneThe matched component/path after it has been fully rendered.
How is this different fromreactpy_router.browser_router?

Thedjango_router component utilizes the same internals asbrowser_router, but provides a more Django-like URL routing syntax.


Last update:December 2, 2024
Authors:Mark Bakhit

[8]ページ先頭

©2009-2025 Movatter.jp