wtf-peewee
this project, based on the code found in wtforms.ext, provides a bridge
between peewee models and wtforms, mapping model fields to form fields.
example usage:
first, create a couple basic models and then use the model_form class factory to create a form for the Entry model:
from peewee import *
from wtfpeewee.orm import model_form
import wtforms
class PasswordField(TextField):
""" Custom-defined field example. """
def wtf_field(self, model, **kwargs):
return wtforms.PasswordField(**kwargs)
class Blog(Model):
name = CharField()
def __unicode__(self):
return self.name
class Entry(Model):
blog = ForeignKeyField(Blog)
title = CharField()
body = TextField()
protected = PasswordField()
def __unicode__(self):
return self.title
# create a form class for use with the Entry model
EntryForm = model_form(Entry)
Example implementation for an "edit" view using Flask:
@app.route('/entries/<int:entry_id>/', methods=['GET', 'POST'])
def edit_entry(entry_id):
try:
entry = Entry.get(id=entry_id)
except Entry.DoesNotExist:
abort(404)
if request.method == 'POST':
form = EntryForm(request.form, obj=entry)
if form.validate():
form.populate_obj(entry)
entry.save()
flash('Your entry has been saved')
else:
form = EntryForm(obj=entry)
return render_template('blog/entry_edit.html', form=form, entry=entry)
Example template for above view:
{% extends "layout.html" %}
{% block body %}
<h2>Edit {{ entry.title }}</h2>
<form method="post" action="">
{% for field in form %}
<p>{{ field.label }} {{ field }}</p>
{% endfor %}
<p><button type="submit">Submit</button></p>
</form>
{% endblock %}
Metadata
Release files for wtf-peewee 3.2.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| wtf_peewee-3.2.1.tar.gz | 68.6 kB | Without provenance | Details for wtf_peewee-3.2.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| wtf_peewee-3.2.1-py3-none-any.whl | Python 3 | none | any | Details for wtf_peewee-3.2.1-py3-none-any.whl |
Total release size: 86.5 kB
Release files / wtf_peewee-3.2.1.tar.gz
| Download URL | wtf_peewee-3.2.1.tar.gz |
|---|---|
| Size | 68.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
830f94a326a5790c1a17b29bc9944b30de97b6cc66e6f9d06895e3ff3a60b211
|
|
BLAKE2b-256 checksum How to use checksums |
18a5fee2253e43cd259f0ea47ff67f4fca15fcf202c04a77db42746300ac8cbf
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Release files / wtf_peewee-3.2.1-py3-none-any.whl
| Download URL | wtf_peewee-3.2.1-py3-none-any.whl |
|---|---|
| Size | 17.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
1bf17e8bc38720aa97b6b5cbb709e31cda7fe1cb53623e2d159f40418e83c380
|
|
BLAKE2b-256 checksum How to use checksums |
aedb79702929fd9e3c78b88403c1d5e3c90d02fc72b3fe6ca7e94e8ff37c33bf
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Security for wtf-peewee 3.2.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.