Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/Pylons/deform
A Python HTML form library.
https://github.com/Pylons/deform
bootstrap chameleon colander deform forms peppercorn pyramid python
Last synced: 2 months ago
JSON representation
A Python HTML form library.
- Host: GitHub
- URL: https://github.com/Pylons/deform
- Owner: Pylons
- License: other
- Created: 2011-02-16T06:29:46.000Z (almost 14 years ago)
- Default Branch: main
- Last Pushed: 2024-06-08T22:42:48.000Z (7 months ago)
- Last Synced: 2024-11-05T05:50:27.526Z (2 months ago)
- Topics: bootstrap, chameleon, colander, deform, forms, peppercorn, pyramid, python
- Language: JavaScript
- Homepage:
- Size: 5.58 MB
- Stars: 417
- Watchers: 33
- Forks: 161
- Open Issues: 59
-
Metadata Files:
- Readme: README.rst
- Changelog: CHANGES.txt
- Contributing: contributing.md
- License: LICENSE.txt
Awesome Lists containing this project
- awesome-python-resources - GitHub - 25% open · ⏱️ 15.07.2022): (表单)
- awesome-pyramid - deform - is a Python HTML form generation (Forms)
- starred-awesome - deform - A Python HTML form library. (JavaScript)
- best-of-web-python - GitHub - 25% open · ⏱️ 15.11.2023): (Web Forms)
- awesome-python-html - Pylons/deform: A Python HTML form library.
- awesome-python-html - Pylons/deform: A Python HTML form library.
README
Deform
======.. image:: https://github.com/Pylons/deform/workflows/Build%20and%20test/badge.svg?branch=main
:target: https://github.com/Pylons/deform/actions?query=workflow%3A%22Build+and+test%22+branch%3Amain
:alt: Build Status.. image:: https://img.shields.io/pypi/v/deform
:target: https://pypi.org/project/deform/
:alt: Current Release.. image:: https://readthedocs.org/projects/deform/badge/?version=main
:target: https://docs.pylonsproject.org/projects/deform/en/main/
:alt: Main Documentation Status.. image:: https://readthedocs.org/projects/deform/badge/?version=latest
:target: https://docs.pylonsproject.org/projects/deform/en/latest/
:alt: Latest Documentation Status.. image:: https://img.shields.io/pypi/pyversions/deform
:alt: Python Support.. contents:: :local:
Introduction
------------Deform is a Python form library for generating HTML forms on the server side.
`Date and time picking widgets `_,
`rich text editors `_, `forms with
dynamically added and removed items
`_ and a few other `complex
use cases `_ are supported out of the box.Deform integrates with the `Pyramid web framework `_
and several other web frameworks. Deform comes with `Chameleon templates
`_ and `Bootstrap 5
`_ styling. Under the hood, `Colander schemas
`_ are used for serialization and
validation. The `Peppercorn `_ library
maps HTTP form submissions to nested structure.Although Deform uses Chameleon templates internally, you can embed rendered
Deform forms into any template language.Use cases
---------Deform is ideal for complex server-side generated forms. Potential use cases
include:* Complex data entry forms
* Administrative interfaces
* Python based websites with high amount of data manipulation forms
* Websites where additional front end framework is not needed
Installation
------------Install using `pip and Python package installation best practices `_::
pip install deform
Example
-------`See all widget examples `_. Below is a sample
form loop using the `Pyramid `_ web framework... image:: https://github.com/Pylons/deform/raw/main/docs/example.png
:width: 400pxExample code:
.. code-block:: python
"""Self-contained Deform demo example."""
from __future__ import print_functionfrom pyramid.config import Configurator
from pyramid.session import UnencryptedCookieSessionFactoryConfig
from pyramid.httpexceptions import HTTPFoundimport colander
import deformclass ExampleSchema(deform.schema.CSRFSchema):
name = colander.SchemaNode(
colander.String(),
title="Name")age = colander.SchemaNode(
colander.Int(),
default=18,
title="Age",
description="Your age in years")def mini_example(request):
"""Sample Deform form with validation."""schema = ExampleSchema().bind(request=request)
# Create a styled button with some extra Bootstrap 3 CSS classes
process_btn = deform.form.Button(name='process', title="Process")
form = deform.form.Form(schema, buttons=(process_btn,))# User submitted this form
if request.method == "POST":
if 'process' in request.POST:try:
appstruct = form.validate(request.POST.items())# Save form data from appstruct
print("Your name:", appstruct["name"])
print("Your age:", appstruct["age"])# Thank user and take him/her to the next page
request.session.flash('Thank you for the submission.')# Redirect to the page shows after succesful form submission
return HTTPFound("/")except deform.exception.ValidationFailure as e:
# Render a form version where errors are visible next to the fields,
# and the submitted values are posted back
rendered_form = e.render()
else:
# Render a form with initial default values
rendered_form = form.render()return {
# This is just rendered HTML in a string
# and can be embedded in any template language
"rendered_form": rendered_form,
}def main(global_config, **settings):
"""pserve entry point"""
session_factory = UnencryptedCookieSessionFactoryConfig('seekrit!')
config = Configurator(settings=settings, session_factory=session_factory)
config.include('pyramid_chameleon')
deform.renderer.configure_zpt_renderer()
config.add_static_view('static_deform', 'deform:static')
config.add_route('mini_example', path='/')
config.add_view(mini_example, route_name="mini_example", renderer="templates/mini.pt")
return config.make_wsgi_app()This example is in `deformdemo repository `_. Run the example with pserve::
pserve mini.ini --reload
Status
------This library is actively developed and maintained. Deform 2.x branch has been used in production on several sites since 2014. Automatic test suite has 100% Python code coverage and 500+ tests.
Projects using Deform
---------------------* `Websauna `_
* `Kotti `_
* `Substance D `_
Community and links
-------------------* `Widget examples `_
* `PyPI `_
* `Issue tracker `_
* `Widget examples repo `_
* `Documentation `_
* `Support `_