Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

134
Vistas
How to change HTMX behavior to replace the full web page if form is invalid

If this form submits as invalid, I want to override the htmx and do a HttpRedirectResponse that refreshes the full page instead of just changing the div, #superdiv, contents.

<form id="create_form" action="." method="post" hx-post="." hx-target="#superdiv" hx swap="outerHTML">
        {{ form }}
        <button id="button" type="submit">Create</button>
    </form>

I have been attempting to do this in the def post of my views.

if form.is_valid():
    return self.form_valid(form)
else:
    return HttpResponseRedirect(reverse_lazy("logs:manager_form"))

Would this be achieved better using JavaScript? I am trying my best to sticking to learning only vanilla JavaScript for now.

Thanks for any help.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

I don't know if you already use it but the django-htmx extension is really good and handy.

You can trigger an entire client refresh from your Django view.

HttpResponseClientRefresh

I hope it is useful 😊

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda