Skip to content

About

Interactive WTForms forms with no hand-written JavaScript, powered by htmx and dark magic.

Topics

Resources

Contributing

Stars

3 stars

Watchers

1 watching

Forks

Repository files navigation

wtforms-htmx

wtforms-htmx

Interactive WTForms forms declared in Python and powered by htmx, with no JavaScript to write, or even any htmx.

Typing a title fills in its slug as you type.

Here's (almost) everything wtforms-htmx adds on top of a regular form:

class PostForm(HtmxForm):
    title = StringField().triggers("slug", slugify)
    slug = StringField()

Features

  • Declare interactivity in Python. Right on the field declaration, not scattered across hx-* attributes.
  • No extra endpoints. Interactions are handled by the form's existing view. You don't write a route for each one.
  • Progressive enhancement. The form works without JavaScript; htmx layers live updates and partial swaps on top. Same form, two render paths.
  • Opinionated defaults, fully overridable. wtforms-htmx renders the right hx-* for you, but they're yours to override.
  • Common patterns in a few lines. Inline validation and FieldList add/remove/reorder are built in. The examples show how to build autocomplete, comboboxes and dependent fields.

Full documentation: https://wtforms-htmx.readthedocs.io/

Related packages

Example app

A runnable gallery of examples lives in examples/. The documentation shows most of them with a screencast. To run it locally:

uv sync --group example
uv run python -m examples

Then open http://127.0.0.1:5000/.

About

Interactive WTForms forms with no hand-written JavaScript, powered by htmx and dark magic.

Topics

Resources

Contributing

Stars

3 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages