Skip to content

Instantly share code, notes, and snippets.

@vishalsodani
Created August 28, 2023 11:22
Show Gist options
  • Save vishalsodani/a19f77ff5cda93122747b03cb7edd440 to your computer and use it in GitHub Desktop.
Save vishalsodani/a19f77ff5cda93122747b03cb7edd440 to your computer and use it in GitHub Desktop.
htmx patterns

return error and and reswap target; this is nice. no need for client side javascript

        error = render_to_string('product_info_error.html',{'error':"test"})
        response = HttpResponse(error)
        response["HX-Retarget"] = "#validation_error"
        response["HX-Reswap"] = "#innerHTML"
        return response
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment