djhtmx 1.0.0__py3-none-any.whl → 1.1.1__py3-none-any.whl

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/__init__.py CHANGED
@@ -1,4 +1,4 @@
1
1
  from .middleware import middleware
2
2
 
3
- __version__ = "1.0.0"
3
+ __version__ = "1.1.1"
4
4
  __all__ = ("middleware",)
djhtmx/command_queue.py CHANGED
@@ -48,7 +48,10 @@ class CommandQueue:
48
48
  else:
49
49
  action = "updated"
50
50
 
51
- signals = get_model_subscriptions(instance, actions=(action,))
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}"
djhtmx/utils.py CHANGED
@@ -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] = ("created", "updated", "deleted"),
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
- result = {(model_prefix := f"{app}.{name}")}
89
- if instance:
90
- result.add(prefix := f"{model_prefix}.{instance.pk}")
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
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: djhtmx
3
- Version: 1.0.0
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
- Add `djhtmx` to your `INSTALLED_APPS` and install the Middleware as the last one
58
- of the list:
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
 
@@ -1,6 +1,6 @@
1
- djhtmx/__init__.py,sha256=BUSbmJ9lD9wO3LhcMG6Uu5ZhfbKtuB3p5ZZ4ONoiUYE,84
1
+ djhtmx/__init__.py,sha256=xrcVGamFk6KoJqtBJy3ACEWX66jWJTfebnCGNPZcAu8,84
2
2
  djhtmx/apps.py,sha256=_Ic52zQLpbYmyuCAlgZ0lF3NDgi77sxptb31snBAN4o,268
3
- djhtmx/command_queue.py,sha256=rgrh1VXWATLhKDMhsV5vDKacg0J4M_2fYbuS8welBi4,4768
3
+ djhtmx/command_queue.py,sha256=kiYbQFPyjnhMSR7KgO1Nu-lWiapnH511P2Pyg-Zrdq4,4862
4
4
  djhtmx/commands.py,sha256=UxXbARd4Teetjh_zjvAWgI2KNbvdETH-WrGf4qD9Xr8,1206
5
5
  djhtmx/component.py,sha256=viqrizs85e6zlGh3Zlf2n2HxfBg1cOaSp5deVGPRGXY,15739
6
6
  djhtmx/consumer.py,sha256=kHNoXokcWaFjs5zbZAhM7Y0x7GVwwawXbxBCkP8HNA8,2839
@@ -16,7 +16,7 @@ djhtmx/settings.py,sha256=ymFUMvrcXDkYU9KkhPOjRZSQMWz5GcUjlgh07x09-1s,1242
16
16
  djhtmx/testing.py,sha256=AdZKsT6sNTsyqSKx6EmfthOIHzSAPkTquheMfg9znbk,8301
17
17
  djhtmx/tracing.py,sha256=xkCXb7t_3yCj1PGzmQfHPu9sYQftDKwtALaEbFVnQ1E,1260
18
18
  djhtmx/urls.py,sha256=zWMlw_udCUWvo5DNxsvbebSNRFxy0C9ghBmRg08XlcU,3894
19
- djhtmx/utils.py,sha256=mEXFSp_eFpxFbO2CiAne5hbvdBGgUl44Pyh_VS7nzho,3610
19
+ djhtmx/utils.py,sha256=gjsJZrjrr7FDh-8wv9W5j3EWNlDl_Eztr5IeMvdY2BE,3617
20
20
  djhtmx/management/commands/htmx.py,sha256=EtJhQofJ4Dl3s34Uihz4WbSljzy5R6r0HXGaX4vkcDg,2011
21
21
  djhtmx/static/htmx/django.js,sha256=G59uwy5hA4QUcAFJv21SMxizATpNZG3KfgFlO2zXeGc,7086
22
22
  djhtmx/static/htmx/2.0.4/htmx.amd.js,sha256=Hgmm_X5zw7ek0pjBaxhzH7OHx6Xfce5UYVa9ICWlWR0,165593
@@ -30,7 +30,7 @@ djhtmx/templates/htmx/headers.html,sha256=rBQTBt9rnlxE8lgxN4U7nvzQZNw4JZKS4flD1V
30
30
  djhtmx/templates/htmx/lazy.html,sha256=LfAThtKmFj-lCUZ7JWF_sC1Y6XsIpEz8A3IgWASn-J8,52
31
31
  djhtmx/templatetags/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
32
32
  djhtmx/templatetags/htmx.py,sha256=HlH7_B9lJoTDoIkYPeEE55OwpBTrrCesE70j1KcRC70,8063
33
- djhtmx-1.0.0.dist-info/METADATA,sha256=Yz8YOhiW1VEyg2Eft5MfzRJSuv0NMGp4Z4g3uT6ma90,28298
34
- djhtmx-1.0.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
35
- djhtmx-1.0.0.dist-info/licenses/LICENSE,sha256=kCi_iSBUGsRZInQn96w7LXYzjiRjZ8FXl6vP--mFRPk,1085
36
- djhtmx-1.0.0.dist-info/RECORD,,
33
+ djhtmx-1.1.1.dist-info/METADATA,sha256=NMrxVSCGCi-0f4X5jWgClss_sMFM_M8vZ7Yx3mipc28,28777
34
+ djhtmx-1.1.1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
35
+ djhtmx-1.1.1.dist-info/licenses/LICENSE,sha256=kCi_iSBUGsRZInQn96w7LXYzjiRjZ8FXl6vP--mFRPk,1085
36
+ djhtmx-1.1.1.dist-info/RECORD,,
File without changes