mirror of
https://github.com/django-components/django-components.git
synced 2025-11-11 19:43:45 +00:00
|
Some checks are pending
Docs - build & deploy / docs (push) Waiting to run
Run tests / build (ubuntu-latest, 3.10) (push) Waiting to run
Run tests / build (ubuntu-latest, 3.11) (push) Waiting to run
Run tests / build (ubuntu-latest, 3.12) (push) Waiting to run
Run tests / build (ubuntu-latest, 3.13) (push) Waiting to run
Run tests / build (ubuntu-latest, 3.8) (push) Waiting to run
Run tests / build (ubuntu-latest, 3.9) (push) Waiting to run
Run tests / build (windows-latest, 3.10) (push) Waiting to run
Run tests / build (windows-latest, 3.11) (push) Waiting to run
Run tests / build (windows-latest, 3.12) (push) Waiting to run
Run tests / build (windows-latest, 3.13) (push) Waiting to run
Run tests / build (windows-latest, 3.8) (push) Waiting to run
Run tests / build (windows-latest, 3.9) (push) Waiting to run
Run tests / test_docs (3.13) (push) Waiting to run
Run tests / test_sampleproject (3.13) (push) Waiting to run
|
||
|---|---|---|
| .. | ||
| __init__.py | ||
| apps.py | ||
| README.md | ||
| urls.py | ||
| utils.py | ||
| views.py | ||
Examples
This Django app dynamically discovers and registers example components from the documentation (docs/examples/).
How it works
-
Discovery: At startup, the app scans
docs/examples/*/directories for:component.py- Component definitions with inline templatespage.py- Page views for live demos
-
Registration: Found modules are imported as:
examples.dynamic.<example_name>.componentexamples.dynamic.<example_name>.page
-
Components: Are automatically registered with django-components registry via
@register()decorators -
URLs: Page views are automatically registered as URL patterns at
examples/<example_name>
Structure
Each example in docs/examples/ follows this structure:
docs/examples/form/
├── README.md # Documentation
├── component.py # Component with inline templates
├── page.py # Page view for live demo
├── test.py # Tests
└── images/ # Screenshots/assets
Live examples
All examples are available as live demos:
- Index page: http://localhost:8000/examples/ - Lists all available examples
- Individual examples:
http://localhost:8000/examples/<example_name>
Adding new examples
- Create a new directory in
docs/examples/<example_name>/ - Add
component.py,page.py, and other files as seen above. - Start the server and open
http://localhost:8000/examples/<example_name>to see the example.