docs: mention URL auto-gen in README (#1099)

This commit is contained in:
Juro Oravec 2025-04-07 19:26:50 +02:00 committed by GitHub
parent 9f9b1f7232
commit 1dfec8fc6d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 20 additions and 4 deletions

View file

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