djhtmx 1.0.0__tar.gz → 1.1.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {djhtmx-1.0.0 → djhtmx-1.1.1}/CHANGELOG.md +20 -6
- {djhtmx-1.0.0 → djhtmx-1.1.1}/PKG-INFO +36 -3
- {djhtmx-1.0.0 → djhtmx-1.1.1}/README.md +35 -2
- {djhtmx-1.0.0 → djhtmx-1.1.1}/src/djhtmx/__init__.py +1 -1
- {djhtmx-1.0.0 → djhtmx-1.1.1}/src/djhtmx/command_queue.py +4 -1
- {djhtmx-1.0.0 → djhtmx-1.1.1}/src/djhtmx/utils.py +5 -5
- {djhtmx-1.0.0 → djhtmx-1.1.1}/.gitignore +0 -0
- {djhtmx-1.0.0 → djhtmx-1.1.1}/LICENSE +0 -0
- {djhtmx-1.0.0 → djhtmx-1.1.1}/MANIFEST.in +0 -0
- {djhtmx-1.0.0 → djhtmx-1.1.1}/pyproject.toml +0 -0
- {djhtmx-1.0.0 → djhtmx-1.1.1}/src/djhtmx/apps.py +0 -0
- {djhtmx-1.0.0 → djhtmx-1.1.1}/src/djhtmx/commands.py +0 -0
- {djhtmx-1.0.0 → djhtmx-1.1.1}/src/djhtmx/component.py +0 -0
- {djhtmx-1.0.0 → djhtmx-1.1.1}/src/djhtmx/consumer.py +0 -0
- {djhtmx-1.0.0 → djhtmx-1.1.1}/src/djhtmx/context.py +0 -0
- {djhtmx-1.0.0 → djhtmx-1.1.1}/src/djhtmx/exceptions.py +0 -0
- {djhtmx-1.0.0 → djhtmx-1.1.1}/src/djhtmx/global_events.py +0 -0
- {djhtmx-1.0.0 → djhtmx-1.1.1}/src/djhtmx/introspection.py +0 -0
- {djhtmx-1.0.0 → djhtmx-1.1.1}/src/djhtmx/json.py +0 -0
- {djhtmx-1.0.0 → djhtmx-1.1.1}/src/djhtmx/management/commands/htmx.py +0 -0
- {djhtmx-1.0.0 → djhtmx-1.1.1}/src/djhtmx/middleware.py +0 -0
- {djhtmx-1.0.0 → djhtmx-1.1.1}/src/djhtmx/query.py +0 -0
- {djhtmx-1.0.0 → djhtmx-1.1.1}/src/djhtmx/repo.py +0 -0
- {djhtmx-1.0.0 → djhtmx-1.1.1}/src/djhtmx/settings.py +0 -0
- {djhtmx-1.0.0 → djhtmx-1.1.1}/src/djhtmx/static/htmx/2.0.4/ext/ws.js +0 -0
- {djhtmx-1.0.0 → djhtmx-1.1.1}/src/djhtmx/static/htmx/2.0.4/htmx.amd.js +0 -0
- {djhtmx-1.0.0 → djhtmx-1.1.1}/src/djhtmx/static/htmx/2.0.4/htmx.cjs.js +0 -0
- {djhtmx-1.0.0 → djhtmx-1.1.1}/src/djhtmx/static/htmx/2.0.4/htmx.esm.d.ts +0 -0
- {djhtmx-1.0.0 → djhtmx-1.1.1}/src/djhtmx/static/htmx/2.0.4/htmx.esm.js +0 -0
- {djhtmx-1.0.0 → djhtmx-1.1.1}/src/djhtmx/static/htmx/2.0.4/htmx.js +0 -0
- {djhtmx-1.0.0 → djhtmx-1.1.1}/src/djhtmx/static/htmx/2.0.4/htmx.min.js +0 -0
- {djhtmx-1.0.0 → djhtmx-1.1.1}/src/djhtmx/static/htmx/django.js +0 -0
- {djhtmx-1.0.0 → djhtmx-1.1.1}/src/djhtmx/templates/htmx/headers.html +0 -0
- {djhtmx-1.0.0 → djhtmx-1.1.1}/src/djhtmx/templates/htmx/lazy.html +0 -0
- {djhtmx-1.0.0 → djhtmx-1.1.1}/src/djhtmx/templatetags/__init__.py +0 -0
- {djhtmx-1.0.0 → djhtmx-1.1.1}/src/djhtmx/templatetags/htmx.py +0 -0
- {djhtmx-1.0.0 → djhtmx-1.1.1}/src/djhtmx/testing.py +0 -0
- {djhtmx-1.0.0 → djhtmx-1.1.1}/src/djhtmx/tracing.py +0 -0
- {djhtmx-1.0.0 → djhtmx-1.1.1}/src/djhtmx/urls.py +0 -0
|
@@ -7,16 +7,30 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [1.1.1] - 2025-08-23
|
|
11
|
+
|
|
12
|
+
- Remove `get_model_subscriptions` `Action` annotation as string literals, as this does not reflect model relationships
|
|
13
|
+
|
|
14
|
+
## [1.1.0] - 2025-08-15
|
|
15
|
+
|
|
16
|
+
### Changed
|
|
17
|
+
- **BREAKING**: Refactored `get_model_subscriptions` to use explicit action parameters instead of auto-subscribing to all actions by default
|
|
18
|
+
- Changed default behavior from implicit subscription to all actions to explicit opt-in only
|
|
19
|
+
- Updated command queue to subscribe to both instance and model-level signals for better coverage
|
|
20
|
+
|
|
10
21
|
### Added
|
|
11
22
|
- **Custom Context Support for Render Command**: The `Render` command now accepts an optional `context` parameter of type `dict[str, Any]`. When provided, this context will override the component's default context during template rendering, while preserving essential HTMX variables (`htmx_repo`, `hx_oob`, `this`). This enables more flexible template rendering scenarios where you need to pass custom data that differs from the component's state.
|
|
23
|
+
- Added type annotation `Action = Literal["created", "updated", "deleted"]` for better type safety
|
|
24
|
+
- Support for `None` in actions parameter to include bare prefix subscriptions
|
|
12
25
|
|
|
13
|
-
###
|
|
14
|
-
- The `Render` dataclass now includes a `context: dict[str, Any] | None = None` field
|
|
26
|
+
### Technical Details
|
|
27
|
+
- The `Render` dataclass now includes a `context: dict[str, Any] | None = None` field
|
|
15
28
|
- The `Repository.render_html` method signature now includes an optional `context` parameter
|
|
16
29
|
- Template rendering logic now supports context override while maintaining backwards compatibility
|
|
17
|
-
|
|
18
|
-
### Technical Details
|
|
19
|
-
- All changes are fully backwards compatible - existing code continues to work without modification
|
|
30
|
+
- All custom context changes are fully backwards compatible - existing code continues to work without modification
|
|
20
31
|
- When `context=None` (default), behavior is identical to previous versions
|
|
21
32
|
- When `context` is provided, it takes precedence over component context but essential HTMX context variables are preserved
|
|
22
|
-
- Comprehensive test coverage added for
|
|
33
|
+
- Comprehensive test coverage added for all new functionality
|
|
34
|
+
|
|
35
|
+
### Migration Guide
|
|
36
|
+
- If you were relying on `get_model_subscriptions()` to automatically subscribe to all actions, you now need to explicitly pass the actions you want: `get_model_subscriptions(instance, actions=["created", "updated", "deleted"])`
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: djhtmx
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.1.1
|
|
4
4
|
Summary: Interactive UI Components for Django using HTMX
|
|
5
5
|
Project-URL: Homepage, https://github.com/edelvalle/djhtmx
|
|
6
6
|
Project-URL: Documentation, https://github.com/edelvalle/djhtmx#readme
|
|
@@ -54,8 +54,19 @@ Interactive UI Components for Django using [htmx](https://htmx.org)
|
|
|
54
54
|
|
|
55
55
|
## Install
|
|
56
56
|
|
|
57
|
-
|
|
58
|
-
|
|
57
|
+
```bash
|
|
58
|
+
uv add djhtmx
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
or
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
pip install djhtmx
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
# Configuration
|
|
68
|
+
|
|
69
|
+
Add `djhtmx` to your `INSTALLED_APPS`.
|
|
59
70
|
|
|
60
71
|
```python
|
|
61
72
|
INSTALLED_APPS = [
|
|
@@ -63,11 +74,33 @@ INSTALLED_APPS = [
|
|
|
63
74
|
"djhtmx",
|
|
64
75
|
...
|
|
65
76
|
]
|
|
77
|
+
```
|
|
66
78
|
|
|
79
|
+
Install the Middleware as the last one of the list
|
|
80
|
+
|
|
81
|
+
```python
|
|
67
82
|
MIDDLEWARE = [
|
|
68
83
|
...,
|
|
69
84
|
"djhtmx.middleware",
|
|
70
85
|
]
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
Add `djhtmx.context.component_repo` to the list of context processors:
|
|
89
|
+
|
|
90
|
+
```python
|
|
91
|
+
TEMPLATES = [
|
|
92
|
+
{
|
|
93
|
+
"BACKEND": "django.template.backends.django.DjangoTemplates",
|
|
94
|
+
"DIRS": [],
|
|
95
|
+
"APP_DIRS": True,
|
|
96
|
+
"OPTIONS": {
|
|
97
|
+
"context_processors": [
|
|
98
|
+
...,
|
|
99
|
+
"djhtmx.context.component_repo",
|
|
100
|
+
],
|
|
101
|
+
},
|
|
102
|
+
},
|
|
103
|
+
]
|
|
71
104
|
|
|
72
105
|
```
|
|
73
106
|
|
|
@@ -7,8 +7,19 @@ Interactive UI Components for Django using [htmx](https://htmx.org)
|
|
|
7
7
|
|
|
8
8
|
## Install
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
```bash
|
|
11
|
+
uv add djhtmx
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
or
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
pip install djhtmx
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
# Configuration
|
|
21
|
+
|
|
22
|
+
Add `djhtmx` to your `INSTALLED_APPS`.
|
|
12
23
|
|
|
13
24
|
```python
|
|
14
25
|
INSTALLED_APPS = [
|
|
@@ -16,11 +27,33 @@ INSTALLED_APPS = [
|
|
|
16
27
|
"djhtmx",
|
|
17
28
|
...
|
|
18
29
|
]
|
|
30
|
+
```
|
|
19
31
|
|
|
32
|
+
Install the Middleware as the last one of the list
|
|
33
|
+
|
|
34
|
+
```python
|
|
20
35
|
MIDDLEWARE = [
|
|
21
36
|
...,
|
|
22
37
|
"djhtmx.middleware",
|
|
23
38
|
]
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
Add `djhtmx.context.component_repo` to the list of context processors:
|
|
42
|
+
|
|
43
|
+
```python
|
|
44
|
+
TEMPLATES = [
|
|
45
|
+
{
|
|
46
|
+
"BACKEND": "django.template.backends.django.DjangoTemplates",
|
|
47
|
+
"DIRS": [],
|
|
48
|
+
"APP_DIRS": True,
|
|
49
|
+
"OPTIONS": {
|
|
50
|
+
"context_processors": [
|
|
51
|
+
...,
|
|
52
|
+
"djhtmx.context.component_repo",
|
|
53
|
+
],
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
]
|
|
24
57
|
|
|
25
58
|
```
|
|
26
59
|
|
|
@@ -48,7 +48,10 @@ class CommandQueue:
|
|
|
48
48
|
else:
|
|
49
49
|
action = "updated"
|
|
50
50
|
|
|
51
|
-
signals = get_model_subscriptions(
|
|
51
|
+
signals = get_model_subscriptions(
|
|
52
|
+
instance, actions=(action, None)
|
|
53
|
+
) | get_model_subscriptions(type(instance), actions=(action, None))
|
|
54
|
+
|
|
52
55
|
for field in get_related_fields(sender):
|
|
53
56
|
fk_id = getattr(instance, field.name)
|
|
54
57
|
signal = f"{field.related_model_name}.{fk_id}.{field.relation_name}"
|
|
@@ -65,7 +65,7 @@ def get_instance_subscriptions(
|
|
|
65
65
|
|
|
66
66
|
def get_model_subscriptions(
|
|
67
67
|
obj: type[models.Model] | models.Model,
|
|
68
|
-
actions: t.Sequence[str] = (
|
|
68
|
+
actions: t.Sequence[str | None] = (),
|
|
69
69
|
) -> set[str]:
|
|
70
70
|
"""Get the subscriptions to actions of the model.
|
|
71
71
|
|
|
@@ -77,6 +77,7 @@ def get_model_subscriptions(
|
|
|
77
77
|
possible relation (e.g 'users.deleted').
|
|
78
78
|
|
|
79
79
|
"""
|
|
80
|
+
actions = actions or (None,)
|
|
80
81
|
if isinstance(obj, models.Model):
|
|
81
82
|
cls = type(obj)
|
|
82
83
|
instance = obj
|
|
@@ -85,10 +86,9 @@ def get_model_subscriptions(
|
|
|
85
86
|
instance = None
|
|
86
87
|
app = cls._meta.app_label
|
|
87
88
|
name = cls._meta.model_name
|
|
88
|
-
|
|
89
|
-
if instance
|
|
90
|
-
|
|
91
|
-
result.update(f"{prefix}.{action}" for action in actions)
|
|
89
|
+
model_prefix = f"{app}.{name}"
|
|
90
|
+
prefix = f"{model_prefix}.{instance.pk}" if instance else model_prefix
|
|
91
|
+
result = {(f"{prefix}.{action}" if action else prefix) for action in actions}
|
|
92
92
|
return result
|
|
93
93
|
|
|
94
94
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|