Thank you for your interest in contributing to Django LiveView! This document provides guidelines and instructions for contributing.
Be respectful, inclusive, and professional. Harassment and discrimination of any kind will not be tolerated.
- Check if the bug has already been reported in Issues
- If not, create a new issue with:
- Clear title and description
- Steps to reproduce
- Expected vs actual behavior
- Django/Python/Browser versions
- Code samples if applicable
- Check if the feature has been requested in Issues
- Create a new issue with:
- Clear description of the feature
- Use cases
- Potential implementation approach
Pull requests are disabled on GitHub. Send your changes as patches by email, following the contribution guidelines:
- Clone the repository
- Make your changes
- Write/update tests
- Update documentation and
CHANGELOG.md - Commit with clear messages
- Generate the patches (
git format-patch origin/main) and send them
- Python 3.10+
- uv
- Node.js 18+ (to build the JavaScript)
- Docker (for the browser tests)
- Git
Redis is not needed: unit tests use the in-memory channel layer and the browser tests start their own Redis.
git clone https://github.com/Django-LiveView/liveview.git
cd liveview
# Create the virtual environment and install development dependencies
uv sync --extra dev
# Or, without uv: python -m venv .venv && pip install -e ".[dev]"
# Install the git hooks (ruff check and ruff format on every commit)
uv run pre-commit install
# Install frontend dependencies
cd frontend
npm install
cd ..Unit tests (Python, no Redis needed: they use the in-memory channel layer):
uv run pytest
# Specific test
uv run pytest tests/test_decorators.py::test_register_stores_handler_by_nameBrowser tests (Playwright) for the navigation history, against the demo
project in tests/e2e, using Docker. They load the built JavaScript, so
build it first after changing frontend/:
cd tests/e2e
docker compose run --rm e2e
# Clean up when finished
docker compose --profile test downSee tests/e2e/README.md for details.
# Lint and format (also run by the pre-commit hook)
uv run ruff check --fix .
uv run ruff format .
# Run every hook on all files
uv run pre-commit run --all-files
# Type check
uv run mypy liveviewcd frontend
# Development build
npm run build
# Production build
npm run build:min
# Watch mode
npm run watchThe build writes liveview/static/liveview/liveview.js and liveview.min.js.
Copy both to django_liveview/static/django_liveview/ as well (old path, still
shipped), so the two copies stay identical. Commit the built files together
with the source change.
django-liveview/
├── liveview/ # Main Python package
│ ├── __init__.py # Public API: send, liveview_handler, liveview_registry
│ ├── apps.py # Auto-discovery of liveview_components modules
│ ├── consumers.py # WebSocket consumer
│ ├── decorators.py # Handler registry and decorator
│ ├── connections.py # send() and broadcasting
│ ├── routing.py # WebSocket URL patterns
│ ├── templatetags/ # {% liveview_room_uuid %}
│ ├── py.typed # PEP 561 typing marker
│ └── static/liveview/ # Built JavaScript
├── django_liveview/static/ # Copy of the built JavaScript (old path)
├── frontend/ # JavaScript source
│ ├── controllers/
│ │ └── page_controller.js # Stimulus controller: data-liveview-* attributes
│ ├── mixins/
│ │ ├── history.js # Back/forward navigation history
│ │ ├── miscellaneous.js # renderHTML and scroll helpers
│ │ └── scripts.js # Execution of inline scripts
│ ├── main.js
│ └── webSocketsCli.js # Connection, reconnection and message queue
├── tests/ # Python unit tests
│ └── e2e/ # Demo project and browser tests
└── docs/ # Documentation
- Follow PEP 8
- Use type hints
- Write docstrings for public APIs
- Keep functions small and focused
- Use meaningful variable names
def send(consumer: Any, data: dict[str, Any], broadcast: bool = False) -> None:
"""
Send a message to the consumer or broadcast it.
Args:
consumer: WebSocket consumer instance (can be None when broadcasting)
data: Message data to send
broadcast: Whether to broadcast to all clients
Raises:
ValueError: If consumer is None when not broadcasting
"""
pass- Use ES6+ features
- Document complex functions
- Keep functions pure when possible
- Use meaningful variable names
- Handle errors gracefully
/**
* Connect to WebSocket server
* @param {string} url - WebSocket URL (optional)
* @return {WebSocket} WebSocket instance
*/
export function connect(url = null) {
// Implementation
}Follow Conventional Commits:
feat: add support for custom WebSocket paths
fix: resolve reconnection race condition
docs: update installation instructions
test: add tests for middleware system
refactor: simplify handler registration
- Update README.md for user-facing changes
- Add docstrings to new Python functions
- Update CHANGELOG.md (Keep a Changelog:
Added/Changed/Fixed) - Update the docs in
docs/:FRONTEND.mdfor attributes andsend()keys,BROWSER_HISTORY.mdfor back/forward behaviour
- New features
- Bug fixes
- Edge cases
- Error handling
Plain pytest functions, one behaviour per test, split in Given / When / Then
blocks. Shared fixtures live in tests/conftest.py.
# tests/test_feature.py
import pytest
from liveview import send
def test_basic_functionality(registry, consumer):
# Given
handler = registry.register("greet")(lambda consumer, content: "hello")
# When
result = handler(consumer, {})
# Then
assert result == "hello"
def test_error_handling(consumer):
# Given
consumer = None
# When / Then
with pytest.raises(ValueError):
send(consumer, {})(For maintainers)
- Check the latest version published on PyPI before choosing the number:
echo django-liveview | uv pip compile --no-deps - - Choose the number with Semantic Versioning: new API or visible behaviour changes are a minor version
- Update the version in
pyproject.toml,setup.pyandliveview/__init__.py(tests/test_version.pychecks they match) - Move the
CHANGELOG.mdentries to a section with the version and date - Commit (
chore: bump version to X.Y.Z) and push - Create and push an annotated tag:
git tag -a vX.Y.Z -m "Release vX.Y.Z - description"andgit push origin vX.Y.Z - Build:
rm -rf dist && uv build - Publish:
uv publish --token <token> - Verify:
uv run --isolated --no-project --refresh --with "django-liveview==X.Y.Z" python -c "import liveview; print(liveview.__version__)"
Feel free to ask questions in GitHub Issues or by email, following the contribution guidelines.
By contributing, you agree that your contributions will be licensed under the MIT License.
Thank you for contributing! 🎉