diff --git a/README.md b/README.md index 41c8e5b9..f8f6043f 100644 --- a/README.md +++ b/README.md @@ -253,12 +253,17 @@ Read more about [HTML attributes](https://django-components.github.io/django-com - Expose components as views with `get`, `post`, `put`, `patch`, `delete` methods +- Automatically create an endpoint for the component with `Component.Url.public` + ```py # components/calendar/calendar.py @register("calendar") class Calendar(Component): template_file = "calendar.html" + class Url: + public = True + class View: def get(self, request, *args, **kwargs): page = request.GET.get("page", 1) @@ -274,8 +279,11 @@ class Calendar(Component): "page": page, } -# urls.py -path("calendar/", Calendar.as_view()), +# Get auto-generated URL for the component +url = get_component_url(Calendar) + +# Or define explicit URL in urls.py +path("calendar/", Calendar.as_view()) ``` ### Type hints diff --git a/docs/overview/welcome.md b/docs/overview/welcome.md index 341fed6b..d24d0718 100644 --- a/docs/overview/welcome.md +++ b/docs/overview/welcome.md @@ -243,12 +243,17 @@ Read more about [HTML attributes](../../concepts/fundamentals/html_attributes/). - Expose components as views with `get`, `post`, `put`, `patch`, `delete` methods +- Automatically create an endpoint for the component with `Component.Url.public` + ```py # components/calendar/calendar.py @register("calendar") class Calendar(Component): template_file = "calendar.html" + class Url: + public = True + class View: def get(self, request, *args, **kwargs): page = request.GET.get("page", 1) @@ -264,8 +269,11 @@ class Calendar(Component): "page": page, } -# urls.py -path("calendar/", Calendar.as_view()), +# Get auto-generated URL for the component +url = get_component_url(Calendar) + +# Or define explicit URL in urls.py +path("calendar/", Calendar.as_view()) ``` ### Type hints diff --git a/requirements-dev.txt b/requirements-dev.txt index f5f68d71..1e82fa6a 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -40,7 +40,7 @@ filelock==3.16.1 # via # tox # virtualenv -flake8==7.1.2 +flake8==7.2.0 # via # -r requirements-dev.in # flake8-pyproject @@ -94,11 +94,11 @@ pluggy==1.5.0 # tox pre-commit==4.2.0 # via -r requirements-dev.in -pycodestyle==2.12.1 +pycodestyle==2.13.0 # via flake8 pyee==12.0.0 # via playwright -pyflakes==3.2.0 +pyflakes==3.3.2 # via flake8 pygments==2.19.1 # via diff --git a/requirements-docs.txt b/requirements-docs.txt index 15a6bb8c..ceac074f 100644 --- a/requirements-docs.txt +++ b/requirements-docs.txt @@ -68,7 +68,7 @@ gitdb==4.0.12 # via gitpython gitpython==3.1.44 # via mkdocs-git-revision-date-localized-plugin -griffe==1.7.1 +griffe==1.7.2 # via mkdocstrings-python htmlmin2==0.1.13 # via mkdocs-minify-plugin