Skip to main content

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


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.6.tar.gz (6.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

django_hornet-0.1.6-py3-none-any.whl (7.6 kB view details)

Uploaded Python 3

File details

Details for the file django_hornet-0.1.6.tar.gz.

File metadata

  • Download URL: django_hornet-0.1.6.tar.gz
  • Upload date:
  • Size: 6.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.25

File hashes

Hashes for django_hornet-0.1.6.tar.gz
Algorithm Hash digest
SHA256 69261f115ea002a96fdefab743d3faa0947f31659433067fa1a9d1bd069fa44e
MD5 38c928705020e5f13eeb3726fa9b7202
BLAKE2b-256 58c786cab9e392423a31125ca4792c5405b75d50a72871628ef36718b1ad7d72

See more details on using hashes here.

File details

Details for the file django_hornet-0.1.6-py3-none-any.whl.

File metadata

  • Download URL: django_hornet-0.1.6-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.25

File hashes

Hashes for django_hornet-0.1.6-py3-none-any.whl
Algorithm Hash digest
SHA256 439c884ec915ae69816d37e5cbdc6642737a12070b9a52f2bbeb09ec0d0ae186
MD5 01d992daedd365ecaffe54a05d8028bb
BLAKE2b-256 9432c9d303fafa3a4a05dab40fc5292249299b0f25c12d113ef3ca723df7fbb1

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page