{"id":13725032,"url":"https://github.com/boardpack/reforms","last_synced_at":"2025-05-04T03:30:51.565Z","repository":{"id":39390601,"uuid":"379424051","full_name":"boardpack/reforms","owner":"boardpack","description":"Reforms is a fresh pydantic-based forms validation and rendering library for Python 3.6+.","archived":false,"fork":false,"pushed_at":"2024-02-16T16:58:48.000Z","size":163,"stargazers_count":25,"open_issues_count":8,"forks_count":5,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-08T02:45:06.178Z","etag":null,"topics":["form","forms","html","package","pydantic","pypi","python","validation"],"latest_commit_sha":null,"homepage":"https://reforms.boardpack.org/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/boardpack.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-06-22T23:19:33.000Z","updated_at":"2025-03-18T22:47:19.000Z","dependencies_parsed_at":"2024-11-13T03:29:41.140Z","dependency_job_id":"d5640bb4-adcc-415c-8b26-f2623d5d19ba","html_url":"https://github.com/boardpack/reforms","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/boardpack%2Freforms","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/boardpack%2Freforms/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/boardpack%2Freforms/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/boardpack%2Freforms/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/boardpack","download_url":"https://codeload.github.com/boardpack/reforms/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252283568,"owners_count":21723498,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["form","forms","html","package","pydantic","pypi","python","validation"],"created_at":"2024-08-03T01:02:10.362Z","updated_at":"2025-05-04T03:30:50.830Z","avatar_url":"https://github.com/boardpack.png","language":"Python","readme":"\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://reforms.boardpack.org/\"\u003e\u003cimg src=\"https://reforms.boardpack.org/img/logo-white.png\" alt=\"Reforms\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\u003c!--\u003cp align=\"center\"\u003e\n    \u003cem\u003eReforms is a fresh pydantic-based forms validation and rendering library for Python 3.6+.\u003c/em\u003e\n\u003c/p\u003e--\u003e\n\u003cp align=\"center\"\u003e\n    \u003ca href=\"https://github.com/boardpack/reforms/actions?query=workflow%3ATest\" target=\"_blank\"\u003e\n        \u003cimg src=\"https://github.com/boardpack/reforms/workflows/Test/badge.svg\" alt=\"Test\"\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://codecov.io/gh/boardpack/reforms\" target=\"_blank\"\u003e\n        \u003cimg src=\"https://img.shields.io/codecov/c/github/boardpack/reforms?color=%2334D058\" alt=\"Coverage\"\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://pypi.org/project/reforms\" target=\"_blank\"\u003e\n        \u003cimg src=\"https://img.shields.io/pypi/v/reforms?color=%2334D058\u0026label=pypi%20package\" alt=\"Package version\"\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://github.com/psf/black\"\u003e\u003cimg alt=\"Code style: black\" src=\"https://camo.githubusercontent.com/d91ed7ac7abbd5a6102cbe988dd8e9ac21bde0a73d97be7603b891ad08ce3479/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f636f64652532307374796c652d626c61636b2d3030303030302e737667\" data-canonical-src=\"https://img.shields.io/badge/code%20style-black-000000.svg\" style=\"max-width:100%;\"\u003e\u003c/a\u003e\n    \u003ca href=\"https://pycqa.github.io/isort/\" rel=\"nofollow\"\u003e\u003cimg src=\"https://camo.githubusercontent.com/fe4a658dd745f746410f961ae45d44355db1cc0e4c09c7877d265c1380248943/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f253230696d706f7274732d69736f72742d2532333136373462313f7374796c653d666c6174266c6162656c436f6c6f723d656638333336\" alt=\"Imports: isort\" data-canonical-src=\"https://img.shields.io/badge/%20imports-isort-%231674b1?style=flat\u0026amp;labelColor=ef8336\" style=\"max-width:100%;\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n\u003ch2\u003e\u003cspan\u003eCURRENTLY, LIBRARY ISN'T UNDER ACTIVE DEVELOPMENT!\u003c/span\u003e\u003c/h2\u003e\n\n---\n\n**Documentation**: \u003ca href=\"https://reforms.boardpack.org\" target=\"_blank\"\u003ehttps://reforms.boardpack.org\u003c/a\u003e\n\n**Source Code**: \u003ca href=\"https://github.com/boardpack/reforms\" target=\"_blank\"\u003ehttps://github.com/boardpack/reforms\u003c/a\u003e\n\n---\n\nReforms is a fresh pydantic-based forms validation and rendering library for Python 3.6+.\n\nThe key features are:\n\n* **Familiar**: Expanded Pydantic retaining all data validation and model creation \ncapabilities.\n* **Easy**: Designed to be easy to use and learn. Less time reading docs.\n* **Theming**: Supported the usage of existing template pack and the creation of your \nown.\n\n## Requirements\n\nPython 3.6+\n\nReforms has the next hard dependencies:\n\n* \u003ca href=\"https://pydantic-docs.helpmanual.io/\" class=\"external-link\" target=\"_blank\"\u003ePydantic\u003c/a\u003e for the data parts.\n* \u003ca href=\"https://jinja.palletsprojects.com/\" class=\"external-link\" target=\"_blank\"\u003eJinja2\u003c/a\u003e for the templates.\n\n## Installation\n\n\u003cdiv class=\"termy\"\u003e\n\n```console\n$ pip install git+http://github.com/boardpack/reforms\n\n---\u003e 100%\n```\n\n\u003c/div\u003e\n\n## Example\n\nIn the next example, we will use \u003ca href=\"https://fastapi.tiangolo.com/\" class=\"external-link\" target=\"_blank\"\u003eFastAPI\u003c/a\u003e\nas a web framework. So you need to install `fastapi` and `uvicorn` first. Also, you \nneed to install `python-multipart` library to turn on forms support in FastAPI.\n\n\u003cdiv class=\"termy\"\u003e\n\n```console\n$ pip install fastapi uvicorn python-multipart\n\n---\u003e 100%\n```\n\n\u003c/div\u003e\n\n### Create it\n\n* Create a file `models.py` with `UserModel` pydantic model:\n\n```Python\nfrom pydantic import BaseModel\n\nfrom reforms import StringField, BooleanField, EmailField\nfrom reforms.validators import Length\n\n\nclass UserModel(BaseModel):\n    first_name: StringField(\n        label=\"First Name\",\n        field_id=\"firstName\",\n        placeholder=\"John\",\n        validators=[Length(min=5)],\n    )\n    last_name: StringField(\n        label=\"Last Name\",\n        field_id=\"lastName\",\n        placeholder=\"Doe\",\n        validators=[Length(min=5)],\n    )\n    email: EmailField(\n        label=\"Email\",\n        field_id=\"email\",\n        placeholder=\"john.doe@example.com\",\n    )\n    has_github: BooleanField(label=\"Has Github account?\", field_id=\"hasGithub\") = False\n\n```\n_(This script is complete, it should run \"as is\")_\n\n* Then you can create a FastAPI application and use this model to generate form \nlayout and validate data. Reforms has special `on_model` function, which works \nwith `Depends` from FastAPI to convert raw form data into pydantic model object. \nCreate a file `main.py` with:\n\n```Python hl_lines=\"8 19 23 28\"\nimport uvicorn\nfrom fastapi import FastAPI, Request, Depends\nfrom fastapi.responses import HTMLResponse, RedirectResponse\nfrom fastapi.templating import Jinja2Templates\nfrom starlette.status import HTTP_302_FOUND\nfrom reforms import Reforms, on_model\n\nfrom models import UserModel\n\napp = FastAPI()\n\nforms = Reforms(package=\"reforms\")\n\ntemplates = Jinja2Templates(directory=\"templates\")\n\n\n@app.get(\"/\", response_class=HTMLResponse)\nasync def index(request: Request):\n    user_form = forms.Form(UserModel)\n\n    return templates.TemplateResponse(\n        \"index.html\",\n        {\"request\": request, \"form\": user_form},\n    )\n\n\n@app.post(\"/\", response_class=RedirectResponse)\nasync def handle_form(form: UserModel = Depends(on_model(UserModel))):\n    print(form)\n    return RedirectResponse(\"/\", status_code=HTTP_302_FOUND)\n\n\nif __name__ == '__main__':\n    uvicorn.run(app)\n\n```\n_(This script is complete, it should run \"as is\")_\n\n* As the last coding step, you need to create a template (now **reforms** supports only \n**jinja2** templates). You can use just form object to render all fields \nsimultaneously or render every field separately (as it mentions in the selected \ncommented line).\n\n```HTML hl_lines=\"10\"\n\u003c!DOCTYPE html\u003e\n\u003chtml lang=\"en\"\u003e\n    \u003chead\u003e\n        \u003cmeta charset=\"UTF-8\"\u003e\n        \u003ctitle\u003eExample reforms page\u003c/title\u003e\n    \u003c/head\u003e\n    \u003cbody\u003e\n        \u003cform action=\"/\" method=\"post\"\u003e\n            {{ form }}\n            {#{{ form.first_name }}#}\n            \u003cbr\u003e\n            \u003cinput type=\"submit\" value=\"Send\"\u003e\n        \u003c/form\u003e\n    \u003c/body\u003e\n\u003c/html\u003e\n```\n_(This template is complete, it should use \"as is\")_\n\n### Run it\n\nRun the server with:\n\n\u003cdiv class=\"termy\"\u003e\n\n```console\n$ uvicorn main:app --reload\n\nINFO:     Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit)\nINFO:     Started reloader process [28720]\nINFO:     Started server process [28722]\nINFO:     Waiting for application startup.\nINFO:     Application startup complete.\n```\n\n\u003c/div\u003e\n\n\u003cdetails markdown=\"1\"\u003e\n\u003csummary\u003eAbout the command \u003ccode\u003euvicorn main:app --reload\u003c/code\u003e...\u003c/summary\u003e\n\nThe command `uvicorn main:app` refers to:\n\n* `main`: the file `main.py` (the Python \"module\").\n* `app`: the object created inside of `main.py` with the line `app = FastAPI()`.\n* `--reload`: make the server restart after code changes. Only do this for development.\n\n\u003c/details\u003e\n\nor just with:\n\n\u003cdiv class=\"termy\"\u003e\n\n```console\n$ python main.py\n\nINFO:     Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit)\nINFO:     Started reloader process [28720]\nINFO:     Started server process [28722]\nINFO:     Waiting for application startup.\nINFO:     Application startup complete.\n```\n\n\u003c/div\u003e\n\n### Send it\n\nOpen your browser at \u003ca href=\"http://127.0.0.1:8000\" class=\"external-link\" target=\"_blank\"\u003ehttp://127.0.0.1:8000\u003c/a\u003e.\n\nYou will see the web form:\n\n![Example form](docs/en/docs/img/index/index-01-web-form.png)\n\nAdd some information like this and click \"Send\" button:\n\n![Passed example form](docs/en/docs/img/index/index-02-web-form-passed.png)\n\n### Check it\n\nFinally, you can see a printed validated model object in your console:\n\n```bash hl_lines=\"8\"\nINFO:     Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit)\nINFO:     Started reloader process [28720]\nINFO:     Started server process [28722]\nINFO:     Waiting for application startup.\nINFO:     Application startup complete.\n\nINFO:     127.0.0.1:33612 - \"GET / HTTP/1.1\" 200 OK\nfirst_name='Roman' last_name='Dukkee' email='example@example.com' has_github=True\nINFO:     127.0.0.1:33872 - \"POST / HTTP/1.1\" 302 Found\nINFO:     127.0.0.1:33872 - \"GET / HTTP/1.1\" 200 OK\n```\n\n## Acknowledgments\n\nSpecial thanks to:\n\n * [Sebastián Ramírez](https://github.com/tiangolo) and his [FastAPI](https://github.com/tiangolo/fastapi) project,  some scripts and documentation structure and parts were used from there.\n \n * [Samuel Colvin](https://github.com/samuelcolvin) and his [Pydantic](https://github.com/samuelcolvin/pydantic/) project.\n\n## License\n\nThis project is licensed under the terms of the MIT license.\n","funding_links":[],"categories":["Python","Libraries"],"sub_categories":["HTML Form Generation"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fboardpack%2Freforms","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fboardpack%2Freforms","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fboardpack%2Freforms/lists"}