Routes
DjangoKit uses a file-based routing system.
On startup, DjangoKit will look for certain files in your project's routes directory and automatically generate Django URLconfs for them.
The parts of the route's path map to a URLconf pattern. Consider the following example:
<package>/
routes/
docs/
page.html ← list of docs
_slug/
page.html ← a single doc
On startup, two routes will be created, roughly equivalent to the following URLconfs:
from django.urls import path
from djangokit.core import RouteView
# NOTE: This is a simplification of how route views are actually
# created. The following views wouldn't actually work without
# passing in the necessary view args.
docs_view = RouteView.as_view()
doc_view = RouteView.as_view()
urlpatterns = [
path("docs", docs_view)),
path("docs/<slug:slug>", doc_view)),
]
Conversion of capture patterns
Any path segment that begins with an underscore, e.g. _name, will be treated as a capture pattern and converted to <name> in the path. The following segments will be converted using a Django URL converter:
_id-><int:id>_slug-><slug:slug>_uuid-><uuid:uuid>
Any other segment will use the default str converter.
Creating routes with the djangokit CLI
Routes can be created using dk add-page or dk add-handler. See Pages and Handlers for more information.