Skip to content

buraq.urls — API Reference

from buraq.urls import get, post, put, patch, delete, path, include
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 methods

Django-style route helper. Defaults to accepting all HTTP methodsGET, 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(module_path: str) -> URLInclude

Include URL patterns from another module.

path("/posts", include("posts.urls"))
register_urlpatterns(app, patterns, prefix="")

Called internally by app.load_urls(). Recursively registers all URLPattern and URLInclude objects with the FastAPI app.

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.

from buraq.urls import reverse_lazy
class MyView(View):
success_url = reverse_lazy("post_list") # not evaluated until used as str

Lazy 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).

@dataclass
class 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