buraq.urls — API Reference
from buraq.urls import get, post, put, patch, delete, path, includeRoute functions
Section titled “Route functions”get(url_path, view, name="", **extra)post(url_path, view, name="", **extra)put(url_path, view, name="", **extra)patch(url_path, view, name="", **extra)delete(url_path, view, name="", **extra)| Param | Description |
|---|---|
url_path |
Path string — Django (/<int:pk>) or FastAPI (/{pk}) style |
view |
Async function or View.as_view() result |
name |
Route name for url_for() in templates |
**extra |
Passed to FastAPI’s route decorator (status_code, tags, response_model, etc.) |
path(url_path, view_or_include, name="", **extra)path(url_path, view_or_include, name="", methods=["GET", "POST"]) # restrict methodsDjango-style route helper. Defaults to accepting all HTTP methods — GET, POST, PUT, PATCH, DELETE, HEAD, OPTIONS. Method dispatch is handled inside the view or CBV. Pass an explicit methods= list to restrict. Also accepts an include() object instead of a view.
include
Section titled “include”include(module_path: str) -> URLIncludeInclude URL patterns from another module.
path("/posts", include("posts.urls"))register_urlpatterns
Section titled “register_urlpatterns”register_urlpatterns(app, patterns, prefix="")Called internally by app.load_urls(). Recursively registers all URLPattern and URLInclude objects with the FastAPI app.
reverse
Section titled “reverse”from buraq.urls import reverse
url = reverse("post_detail", pk=1) # → "/posts/1"Reverse a named URL pattern. Raises NoReverseMatch if the name is not registered or required path params are missing.
reverse_lazy
Section titled “reverse_lazy”from buraq.urls import reverse_lazy
class MyView(View): success_url = reverse_lazy("post_list") # not evaluated until used as strLazy URL reversal — the URL is not resolved until the value is coerced to a string. Use this at class body level where the URL registry may not yet be fully populated (e.g. success_url on a CBV, a default argument, a module-level constant).
URLPattern
Section titled “URLPattern”@dataclassclass URLPattern: path: str # FastAPI-style path, e.g. /posts/{pk} view: Callable name: str methods: list[str] # ["GET"] extra: dict param_types: dict # {"pk": int} — extracted from Django-style converters