feat: websockets
CI / test (push) Successful in 1m56s
CI / build (push) Successful in 48s

This commit is contained in:
2026-07-31 14:27:50 +02:00
parent 125c9dd186
commit 393b39cacd
13 changed files with 626 additions and 2 deletions
@@ -50,6 +50,23 @@
{{ form.attribute_values.errors }}
</div>
{% if price_form %}
<div class="mb-4 max-w-md">
<h4 class="text-sm font-medium opacity-70 mb-1">Precio inicial (opcional)</h4>
<div class="grid grid-cols-1 sm:grid-cols-2 gap-4">
<div>
{{ price_form.price }}
{{ price_form.price.errors }}
</div>
<div>
{{ price_form.tax }}
{{ price_form.tax.errors }}
</div>
</div>
{{ price_form.non_field_errors }}
</div>
{% endif %}
{{ form.non_field_errors }}
<div class="modal-action">
@@ -0,0 +1,24 @@
{% extends 'backoffice/base.html' %}
{% block title %}Demo WebSocket{% endblock %}
{% block extra_js %}
<script src="https://unpkg.com/htmx-ext-ws@2.0.1/ws.js"></script>
{% endblock %}
{% block main %}
<h1 class="text-2xl font-semibold mb-4">Demo WebSocket</h1>
<p class="mb-4 opacity-70">
Verifica el cableado de Django Channels + htmx: el formulario envía el mensaje por WebSocket y
<code>EchoConsumer</code> lo devuelve como HTML que se añade al registro de abajo.
</p>
<div hx-ext="ws" ws-connect="/ws/backoffice/echo/" class="max-w-md">
<form ws-send class="flex gap-2 mb-4">
<input type="text" name="message" class="input input-bordered w-full" placeholder="Escribe un mensaje" autocomplete="off">
<button class="btn btn-primary">Enviar</button>
</form>
</div>
<div id="ws-demo-log" class="flex flex-col gap-1 max-w-md"></div>
{% endblock %}