djhtmx 1.1.0__tar.gz → 1.1.2__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.1.0 → djhtmx-1.1.2}/CHANGELOG.md +16 -0
- {djhtmx-1.1.0 → djhtmx-1.1.2}/PKG-INFO +88 -3
- {djhtmx-1.1.0 → djhtmx-1.1.2}/README.md +87 -2
- {djhtmx-1.1.0 → djhtmx-1.1.2}/src/djhtmx/__init__.py +1 -1
- {djhtmx-1.1.0 → djhtmx-1.1.2}/src/djhtmx/introspection.py +5 -2
- {djhtmx-1.1.0 → djhtmx-1.1.2}/src/djhtmx/utils.py +1 -4
- {djhtmx-1.1.0 → djhtmx-1.1.2}/.gitignore +0 -0
- {djhtmx-1.1.0 → djhtmx-1.1.2}/LICENSE +0 -0
- {djhtmx-1.1.0 → djhtmx-1.1.2}/MANIFEST.in +0 -0
- {djhtmx-1.1.0 → djhtmx-1.1.2}/pyproject.toml +0 -0
- {djhtmx-1.1.0 → djhtmx-1.1.2}/src/djhtmx/apps.py +0 -0
- {djhtmx-1.1.0 → djhtmx-1.1.2}/src/djhtmx/command_queue.py +0 -0
- {djhtmx-1.1.0 → djhtmx-1.1.2}/src/djhtmx/commands.py +0 -0
- {djhtmx-1.1.0 → djhtmx-1.1.2}/src/djhtmx/component.py +0 -0
- {djhtmx-1.1.0 → djhtmx-1.1.2}/src/djhtmx/consumer.py +0 -0
- {djhtmx-1.1.0 → djhtmx-1.1.2}/src/djhtmx/context.py +0 -0
- {djhtmx-1.1.0 → djhtmx-1.1.2}/src/djhtmx/exceptions.py +0 -0
- {djhtmx-1.1.0 → djhtmx-1.1.2}/src/djhtmx/global_events.py +0 -0
- {djhtmx-1.1.0 → djhtmx-1.1.2}/src/djhtmx/json.py +0 -0
- {djhtmx-1.1.0 → djhtmx-1.1.2}/src/djhtmx/management/commands/htmx.py +0 -0
- {djhtmx-1.1.0 → djhtmx-1.1.2}/src/djhtmx/middleware.py +0 -0
- {djhtmx-1.1.0 → djhtmx-1.1.2}/src/djhtmx/query.py +0 -0
- {djhtmx-1.1.0 → djhtmx-1.1.2}/src/djhtmx/repo.py +0 -0
- {djhtmx-1.1.0 → djhtmx-1.1.2}/src/djhtmx/settings.py +0 -0
- {djhtmx-1.1.0 → djhtmx-1.1.2}/src/djhtmx/static/htmx/2.0.4/ext/ws.js +0 -0
- {djhtmx-1.1.0 → djhtmx-1.1.2}/src/djhtmx/static/htmx/2.0.4/htmx.amd.js +0 -0
- {djhtmx-1.1.0 → djhtmx-1.1.2}/src/djhtmx/static/htmx/2.0.4/htmx.cjs.js +0 -0
- {djhtmx-1.1.0 → djhtmx-1.1.2}/src/djhtmx/static/htmx/2.0.4/htmx.esm.d.ts +0 -0
- {djhtmx-1.1.0 → djhtmx-1.1.2}/src/djhtmx/static/htmx/2.0.4/htmx.esm.js +0 -0
- {djhtmx-1.1.0 → djhtmx-1.1.2}/src/djhtmx/static/htmx/2.0.4/htmx.js +0 -0
- {djhtmx-1.1.0 → djhtmx-1.1.2}/src/djhtmx/static/htmx/2.0.4/htmx.min.js +0 -0
- {djhtmx-1.1.0 → djhtmx-1.1.2}/src/djhtmx/static/htmx/django.js +0 -0
- {djhtmx-1.1.0 → djhtmx-1.1.2}/src/djhtmx/templates/htmx/headers.html +0 -0
- {djhtmx-1.1.0 → djhtmx-1.1.2}/src/djhtmx/templates/htmx/lazy.html +0 -0
- {djhtmx-1.1.0 → djhtmx-1.1.2}/src/djhtmx/templatetags/__init__.py +0 -0
- {djhtmx-1.1.0 → djhtmx-1.1.2}/src/djhtmx/templatetags/htmx.py +0 -0
- {djhtmx-1.1.0 → djhtmx-1.1.2}/src/djhtmx/testing.py +0 -0
- {djhtmx-1.1.0 → djhtmx-1.1.2}/src/djhtmx/tracing.py +0 -0
- {djhtmx-1.1.0 → djhtmx-1.1.2}/src/djhtmx/urls.py +0 -0
|
@@ -7,6 +7,22 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [1.1.2] - 2025-08-27
|
|
11
|
+
|
|
12
|
+
### Fixed
|
|
13
|
+
- **Python 3.13 Compatibility**: Added support for `defaultdict[..., ...]` type annotations in Query introspection
|
|
14
|
+
- Fixed type checking for generic aliases in collection annotations
|
|
15
|
+
|
|
16
|
+
### Documentation
|
|
17
|
+
- **Redis Dependency**: Added clear documentation that Redis is required and must be installed separately
|
|
18
|
+
- **Framework Clarification**: Clarified that djhtmx is a framework, not a component library - no pre-built components are provided
|
|
19
|
+
- **Settings Documentation**: Added comprehensive documentation for all available Django settings
|
|
20
|
+
- **Installation Guide**: Added Redis installation instructions for different platforms
|
|
21
|
+
|
|
22
|
+
## [1.1.1] - 2025-08-23
|
|
23
|
+
|
|
24
|
+
- Remove `get_model_subscriptions` `Action` annotation as string literals, as this does not reflect model relationships
|
|
25
|
+
|
|
10
26
|
## [1.1.0] - 2025-08-15
|
|
11
27
|
|
|
12
28
|
### Changed
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: djhtmx
|
|
3
|
-
Version: 1.1.
|
|
3
|
+
Version: 1.1.2
|
|
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,33 @@ 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
|
+
## Requirements
|
|
70
|
+
|
|
71
|
+
djhtmx requires **Redis** to be running for session storage and component state management.
|
|
72
|
+
|
|
73
|
+
**Important**: Redis is not included with djhtmx and must be installed separately on your system. Make sure Redis is installed and accessible before using djhtmx.
|
|
74
|
+
|
|
75
|
+
### Installing Redis
|
|
76
|
+
|
|
77
|
+
- **macOS**: `brew install redis`
|
|
78
|
+
- **Ubuntu/Debian**: `sudo apt-get install redis-server`
|
|
79
|
+
- **CentOS/RHEL**: `sudo yum install redis` or `sudo dnf install redis`
|
|
80
|
+
- **Docker**: `docker run -d -p 6379:6379 redis:alpine`
|
|
81
|
+
- **Windows**: Download from [Redis for Windows](https://github.com/microsoftarchive/redis/releases)
|
|
82
|
+
|
|
83
|
+
Add `djhtmx` to your `INSTALLED_APPS`.
|
|
59
84
|
|
|
60
85
|
```python
|
|
61
86
|
INSTALLED_APPS = [
|
|
@@ -63,11 +88,33 @@ INSTALLED_APPS = [
|
|
|
63
88
|
"djhtmx",
|
|
64
89
|
...
|
|
65
90
|
]
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
Install the Middleware as the last one of the list
|
|
66
94
|
|
|
95
|
+
```python
|
|
67
96
|
MIDDLEWARE = [
|
|
68
97
|
...,
|
|
69
98
|
"djhtmx.middleware",
|
|
70
99
|
]
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
Add `djhtmx.context.component_repo` to the list of context processors:
|
|
103
|
+
|
|
104
|
+
```python
|
|
105
|
+
TEMPLATES = [
|
|
106
|
+
{
|
|
107
|
+
"BACKEND": "django.template.backends.django.DjangoTemplates",
|
|
108
|
+
"DIRS": [],
|
|
109
|
+
"APP_DIRS": True,
|
|
110
|
+
"OPTIONS": {
|
|
111
|
+
"context_processors": [
|
|
112
|
+
...,
|
|
113
|
+
"djhtmx.context.component_repo",
|
|
114
|
+
],
|
|
115
|
+
},
|
|
116
|
+
},
|
|
117
|
+
]
|
|
71
118
|
|
|
72
119
|
```
|
|
73
120
|
|
|
@@ -83,6 +130,40 @@ urlpatterns = [
|
|
|
83
130
|
]
|
|
84
131
|
```
|
|
85
132
|
|
|
133
|
+
## Settings
|
|
134
|
+
|
|
135
|
+
djhtmx can be configured through Django settings:
|
|
136
|
+
|
|
137
|
+
### Required Settings
|
|
138
|
+
|
|
139
|
+
- **`DJHTMX_REDIS_URL`** (default: `"redis://localhost/0"`): Redis connection URL for session storage and component state management.
|
|
140
|
+
|
|
141
|
+
### Optional Settings
|
|
142
|
+
|
|
143
|
+
- **`DJHTMX_SESSION_TTL`** (default: `3600`): Session timeout in seconds. Can be an integer or a `datetime.timedelta` object.
|
|
144
|
+
- **`DJHTMX_DEFAULT_LAZY_TEMPLATE`** (default: `"htmx/lazy.html"`): Default template for lazy-loaded components.
|
|
145
|
+
- **`DJHTMX_ENABLE_SENTRY_TRACING`** (default: `True`): Enable Sentry tracing integration.
|
|
146
|
+
- **`DJHTMX_ENABLE_LOGFIRE_TRACING`** (default: `False`): Enable Logfire tracing integration.
|
|
147
|
+
- **`DJHTMX_STRICT_EVENT_HANDLER_CONSISTENCY_CHECK`** (default: `False`): Enable strict consistency checking for event handlers.
|
|
148
|
+
- **`DJHTMX_KEY_SIZE_ERROR_THRESHOLD`** (default: `0`): Threshold in bytes for session key size errors (0 = disabled).
|
|
149
|
+
- **`DJHTMX_KEY_SIZE_WARN_THRESHOLD`** (default: `51200`): Threshold in bytes for session key size warnings (50KB).
|
|
150
|
+
- **`DJHTMX_KEY_SIZE_SAMPLE_PROB`** (default: `0.1`): Probability for sampling session key size checks.
|
|
151
|
+
|
|
152
|
+
### Example Configuration
|
|
153
|
+
|
|
154
|
+
```python
|
|
155
|
+
# settings.py
|
|
156
|
+
|
|
157
|
+
# Redis connection (required)
|
|
158
|
+
DJHTMX_REDIS_URL = "redis://localhost:6379/0" # or redis://user:password@host:port/db
|
|
159
|
+
|
|
160
|
+
# Optional settings
|
|
161
|
+
DJHTMX_SESSION_TTL = 7200 # 2 hours
|
|
162
|
+
DJHTMX_DEFAULT_LAZY_TEMPLATE = "my_app/lazy_component.html"
|
|
163
|
+
DJHTMX_ENABLE_SENTRY_TRACING = True
|
|
164
|
+
DJHTMX_KEY_SIZE_WARN_THRESHOLD = 100 * 1024 # 100KB
|
|
165
|
+
```
|
|
166
|
+
|
|
86
167
|
In your base template you need to load the necessary scripts to make this work
|
|
87
168
|
|
|
88
169
|
```html
|
|
@@ -97,6 +178,10 @@ In your base template you need to load the necessary scripts to make this work
|
|
|
97
178
|
|
|
98
179
|
## Getting started
|
|
99
180
|
|
|
181
|
+
**Important**: djhtmx is a framework for building interactive components, not a component library. No pre-built components, templates, or behaviors are provided. You need to create your own components from scratch using the framework's base classes and conventions.
|
|
182
|
+
|
|
183
|
+
This library is opinionated about how to use HTMX with Django, but it is not opinionated about components, styling, or specific functionality. You have complete freedom to design and implement your components as needed for your application.
|
|
184
|
+
|
|
100
185
|
This app will look for `htmx.py` files in your app and registers all components found there, but if you load any module where you have components manually when Django boots up, that also works.
|
|
101
186
|
|
|
102
187
|
```python
|
|
@@ -7,8 +7,33 @@ 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
|
+
## Requirements
|
|
23
|
+
|
|
24
|
+
djhtmx requires **Redis** to be running for session storage and component state management.
|
|
25
|
+
|
|
26
|
+
**Important**: Redis is not included with djhtmx and must be installed separately on your system. Make sure Redis is installed and accessible before using djhtmx.
|
|
27
|
+
|
|
28
|
+
### Installing Redis
|
|
29
|
+
|
|
30
|
+
- **macOS**: `brew install redis`
|
|
31
|
+
- **Ubuntu/Debian**: `sudo apt-get install redis-server`
|
|
32
|
+
- **CentOS/RHEL**: `sudo yum install redis` or `sudo dnf install redis`
|
|
33
|
+
- **Docker**: `docker run -d -p 6379:6379 redis:alpine`
|
|
34
|
+
- **Windows**: Download from [Redis for Windows](https://github.com/microsoftarchive/redis/releases)
|
|
35
|
+
|
|
36
|
+
Add `djhtmx` to your `INSTALLED_APPS`.
|
|
12
37
|
|
|
13
38
|
```python
|
|
14
39
|
INSTALLED_APPS = [
|
|
@@ -16,11 +41,33 @@ INSTALLED_APPS = [
|
|
|
16
41
|
"djhtmx",
|
|
17
42
|
...
|
|
18
43
|
]
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
Install the Middleware as the last one of the list
|
|
19
47
|
|
|
48
|
+
```python
|
|
20
49
|
MIDDLEWARE = [
|
|
21
50
|
...,
|
|
22
51
|
"djhtmx.middleware",
|
|
23
52
|
]
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
Add `djhtmx.context.component_repo` to the list of context processors:
|
|
56
|
+
|
|
57
|
+
```python
|
|
58
|
+
TEMPLATES = [
|
|
59
|
+
{
|
|
60
|
+
"BACKEND": "django.template.backends.django.DjangoTemplates",
|
|
61
|
+
"DIRS": [],
|
|
62
|
+
"APP_DIRS": True,
|
|
63
|
+
"OPTIONS": {
|
|
64
|
+
"context_processors": [
|
|
65
|
+
...,
|
|
66
|
+
"djhtmx.context.component_repo",
|
|
67
|
+
],
|
|
68
|
+
},
|
|
69
|
+
},
|
|
70
|
+
]
|
|
24
71
|
|
|
25
72
|
```
|
|
26
73
|
|
|
@@ -36,6 +83,40 @@ urlpatterns = [
|
|
|
36
83
|
]
|
|
37
84
|
```
|
|
38
85
|
|
|
86
|
+
## Settings
|
|
87
|
+
|
|
88
|
+
djhtmx can be configured through Django settings:
|
|
89
|
+
|
|
90
|
+
### Required Settings
|
|
91
|
+
|
|
92
|
+
- **`DJHTMX_REDIS_URL`** (default: `"redis://localhost/0"`): Redis connection URL for session storage and component state management.
|
|
93
|
+
|
|
94
|
+
### Optional Settings
|
|
95
|
+
|
|
96
|
+
- **`DJHTMX_SESSION_TTL`** (default: `3600`): Session timeout in seconds. Can be an integer or a `datetime.timedelta` object.
|
|
97
|
+
- **`DJHTMX_DEFAULT_LAZY_TEMPLATE`** (default: `"htmx/lazy.html"`): Default template for lazy-loaded components.
|
|
98
|
+
- **`DJHTMX_ENABLE_SENTRY_TRACING`** (default: `True`): Enable Sentry tracing integration.
|
|
99
|
+
- **`DJHTMX_ENABLE_LOGFIRE_TRACING`** (default: `False`): Enable Logfire tracing integration.
|
|
100
|
+
- **`DJHTMX_STRICT_EVENT_HANDLER_CONSISTENCY_CHECK`** (default: `False`): Enable strict consistency checking for event handlers.
|
|
101
|
+
- **`DJHTMX_KEY_SIZE_ERROR_THRESHOLD`** (default: `0`): Threshold in bytes for session key size errors (0 = disabled).
|
|
102
|
+
- **`DJHTMX_KEY_SIZE_WARN_THRESHOLD`** (default: `51200`): Threshold in bytes for session key size warnings (50KB).
|
|
103
|
+
- **`DJHTMX_KEY_SIZE_SAMPLE_PROB`** (default: `0.1`): Probability for sampling session key size checks.
|
|
104
|
+
|
|
105
|
+
### Example Configuration
|
|
106
|
+
|
|
107
|
+
```python
|
|
108
|
+
# settings.py
|
|
109
|
+
|
|
110
|
+
# Redis connection (required)
|
|
111
|
+
DJHTMX_REDIS_URL = "redis://localhost:6379/0" # or redis://user:password@host:port/db
|
|
112
|
+
|
|
113
|
+
# Optional settings
|
|
114
|
+
DJHTMX_SESSION_TTL = 7200 # 2 hours
|
|
115
|
+
DJHTMX_DEFAULT_LAZY_TEMPLATE = "my_app/lazy_component.html"
|
|
116
|
+
DJHTMX_ENABLE_SENTRY_TRACING = True
|
|
117
|
+
DJHTMX_KEY_SIZE_WARN_THRESHOLD = 100 * 1024 # 100KB
|
|
118
|
+
```
|
|
119
|
+
|
|
39
120
|
In your base template you need to load the necessary scripts to make this work
|
|
40
121
|
|
|
41
122
|
```html
|
|
@@ -50,6 +131,10 @@ In your base template you need to load the necessary scripts to make this work
|
|
|
50
131
|
|
|
51
132
|
## Getting started
|
|
52
133
|
|
|
134
|
+
**Important**: djhtmx is a framework for building interactive components, not a component library. No pre-built components, templates, or behaviors are provided. You need to create your own components from scratch using the framework's base classes and conventions.
|
|
135
|
+
|
|
136
|
+
This library is opinionated about how to use HTMX with Django, but it is not opinionated about components, styling, or specific functionality. You have complete freedom to design and implement your components as needed for your application.
|
|
137
|
+
|
|
53
138
|
This app will look for `htmx.py` files in your app and registers all components found there, but if you load any module where you have components manually when Django boots up, that also works.
|
|
54
139
|
|
|
55
140
|
```python
|
|
@@ -419,9 +419,12 @@ def is_simple_annotation(ann):
|
|
|
419
419
|
|
|
420
420
|
|
|
421
421
|
def is_collection_annotation(ann):
|
|
422
|
-
|
|
422
|
+
if isinstance(ann, types.GenericAlias):
|
|
423
|
+
return issubclass_safe(ann.__origin__, _COLLECTION_TYPES)
|
|
424
|
+
else:
|
|
425
|
+
return issubclass_safe(ann, _COLLECTION_TYPES)
|
|
423
426
|
|
|
424
427
|
|
|
425
428
|
Unset = object()
|
|
426
429
|
_SIMPLE_TYPES = (int, str, float, UUID, types.NoneType, date, datetime, bool)
|
|
427
|
-
_COLLECTION_TYPES = (dict, tuple, list, set)
|
|
430
|
+
_COLLECTION_TYPES = (dict, tuple, list, set, defaultdict)
|
|
@@ -63,12 +63,9 @@ def get_instance_subscriptions(
|
|
|
63
63
|
return {f"{prefix}.{action}" for action in actions}
|
|
64
64
|
|
|
65
65
|
|
|
66
|
-
Action = t.Literal["created", "updated", "deleted"]
|
|
67
|
-
|
|
68
|
-
|
|
69
66
|
def get_model_subscriptions(
|
|
70
67
|
obj: type[models.Model] | models.Model,
|
|
71
|
-
actions: t.Sequence[
|
|
68
|
+
actions: t.Sequence[str | None] = (),
|
|
72
69
|
) -> set[str]:
|
|
73
70
|
"""Get the subscriptions to actions of the model.
|
|
74
71
|
|
|
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
|