django-hornet
pip install django-hornet
MIDDLEWARE = [
...
"django.middleware.csrf.CsrfViewMiddleware",
"django_hornet.middleware.HtmxMiddleware",
...
]
Example
from django_hornet.views import HornetView
class CounterView(HornetView):
template_name = "counter.html"
component_name = "counter"
def get(self, request, *args, **kwargs):
return self.render_to_component(self.html)
def post(self, request, *args, **kwargs):
action = request.POST.get("action")
if action == "increment":
self.component.increment()
elif action == "decrement":
self.component.decrement()
return self.update_to_component()
<div id="result">
<button
hx-post="{% url 'counter' %}"
hx-vals='{"action": "decrement"}'
hx-target="#result"
>
-
</button>
<span>{{ count }}</span>
<button
hx-post="{% url 'counter' %}"
hx-vals='{"action": "increment"}'
hx-target="#result"
>
+
</button>
</div>
Metadata
Release files for django-hornet 0.1.6
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| django_hornet-0.1.6.tar.gz | 6.4 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| django_hornet-0.1.6-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 14.1 kB
Release files / django_hornet-0.1.6.tar.gz
| Download URL | django_hornet-0.1.6.tar.gz |
|---|---|
| Size | 6.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
69261f115ea002a96fdefab743d3faa0947f31659433067fa1a9d1bd069fa44e
|
|
BLAKE2b-256 checksum How to use checksums |
58c786cab9e392423a31125ca4792c5405b75d50a72871628ef36718b1ad7d72
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.25
|
Release files / django_hornet-0.1.6-py3-none-any.whl
| Download URL | django_hornet-0.1.6-py3-none-any.whl |
|---|---|
| Size | 7.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
439c884ec915ae69816d37e5cbdc6642737a12070b9a52f2bbeb09ec0d0ae186
|
|
BLAKE2b-256 checksum How to use checksums |
9432c9d303fafa3a4a05dab40fc5292249299b0f25c12d113ef3ca723df7fbb1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.25
|