Django Hornet Wrapper
Project description
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>
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
django_hornet-0.1.5.tar.gz
(6.4 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file django_hornet-0.1.5.tar.gz.
File metadata
- Download URL: django_hornet-0.1.5.tar.gz
- Upload date:
- Size: 6.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.24
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9b7dc3ee86e2d82027ef445c54c661de1fb7e25f3713a3fe8a7314b2c4823d81
|
|
| MD5 |
072ec03978a896decc125c4f74da26e3
|
|
| BLAKE2b-256 |
f0bc074d2e8143555cb9e0d48b5c6e0ec13668d9dbbd8ad1da6a461b4d3cec92
|
File details
Details for the file django_hornet-0.1.5-py3-none-any.whl.
File metadata
- Download URL: django_hornet-0.1.5-py3-none-any.whl
- Upload date:
- Size: 7.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.24
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b65b623ebfca021eefd1eb92531ae68d6b8a0970cb18cd7587dc62ccab595806
|
|
| MD5 |
f3bd375b72850365b33fb0eca1e6938e
|
|
| BLAKE2b-256 |
af59675b0c4fb5a8224c29965c9dc39d8941c7261178deb19bc13a1c3483aac4
|