Skip to main content

Create HTML boilerplate from pydantic models

Project description

Dainty

Dainty is a simple, plug and play extension of pydantic, that allows you to easily create HTML input elements based on your pydantic models.

Installation

uv add dainty

Usage

from typing import Literal

from dainty import DaintyModel

class MyModel(DaintyModel):
    name: str
    age: int
    gender: Literal["Male", "Female", "Non Binary", "Other"]

MyModel.to_html(form=True)

This will generate the following HTML:

<form method="post">
  <label for="name">Name: </label>
  <input type="text" name="name" id="name" value="" required />
  <br /><br />
  <label for="age">Age: </label>
  <input
    type="number"
    name="age"
    id="age"
    value=""
    step="1"
    min=""
    max=""
    required
  />
  <br /><br />
  <label for="gender">Gender: </label>
  <select name="gender" id="gender" required>
    <option value="Male">Male</option>
    <option value="Female">Female</option>
    <option value="Non Binary">Non Binary</option>
    <option value="Other">Other</option>
  </select>
  <br /><br />
  <input type="submit" value="Submit" />
</form>

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

dainty-0.2.2.tar.gz (12.7 kB view details)

Uploaded Source

Built Distribution

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

dainty-0.2.2-py3-none-any.whl (3.8 kB view details)

Uploaded Python 3

File details

Details for the file dainty-0.2.2.tar.gz.

File metadata

  • Download URL: dainty-0.2.2.tar.gz
  • Upload date:
  • Size: 12.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.4.30

File hashes

Hashes for dainty-0.2.2.tar.gz
Algorithm Hash digest
SHA256 dab22f352c6ea4165489f89b2f8e89e8275e717a0b8264bd9ed20e01aa45e271
MD5 8b64d770259cf261b2834d2ce23a5f71
BLAKE2b-256 4447d3f1a6bc91dc7396c2ca155fc1af357961dae0cdcdc7e4de21cfe41c44cc

See more details on using hashes here.

File details

Details for the file dainty-0.2.2-py3-none-any.whl.

File metadata

  • Download URL: dainty-0.2.2-py3-none-any.whl
  • Upload date:
  • Size: 3.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.4.30

File hashes

Hashes for dainty-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 ff9bf593d84e14cb507efbf43506fe1ec897d1cb5e8fdc6264cd73ebaa76a0bd
MD5 0b918e3c41fe4fe1eb8212f7b21fcb78
BLAKE2b-256 71629fd533e22b58de67d44b24467afbdee0289611923dc880593f88faad9d60

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