Good forms for Django
GoodForms — rails-like renderer for your form fields. Provide fully control of filed styles and attributes. It’s not replacement for django.forms.
Installation
Run pip install django-goodforms and add goodforms to INSTALLED_APPS. That’s all.
Usage
The view:
from django.shortcuts import render
from django import forms
class LoginForm(forms.Form):
username = forms.CharField()
password = forms.PasswordField()
def sign_up(request):
from = MyForm(initial={'username': 'johnsmith'})
return render(request, 'index.html', {'form': form})
The template:
{% load form_fields %}
{% form name="login" class="login-form" %}
{% textfield form.username class="login-form_input" %}
{% textfield form.password class="login-form_input" %}
{% submit_button "Login" %}
{% endform %}
Controls
Form tag
Form tag automatically inject csrf-token.
Fields use name attribute as prefix for id and for in labels.
{% form name="myform" %}
<!-- Form content -->
{% endform %}
Textfield and Textarea
{% textfield form.title **kwargs %}
{% textarea form.description **kwargs %}
Select
{% select form.country values="ru:Russia,de:Germany" %}
You can use any dict, iterable collection or queryset as values list:
{% select form.county values=any_iterable_object value_key="code" label_key="title" %}
Tips
You can use any of field without a form class:
{% input "username" required=True %}
{% select "city" values="1:New York, 2:London" %}
Settigns
GOODFORMS_XHTML — Enable or disable XHTML syntax (default: False)
GOODFORMS_AUTO_ID — Automatically generate id and for attributes for fields and labels (default: True)
GOODFORMS_ID_PREFIX — Prefix for auto-generated id and for attributes. For forms without name attribute (default: field)
License
Licensed under the MIT license.
Metadata
Release files for django-goodforms 0.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 | |
|---|---|---|---|---|
| django-goodforms-0.2.1.tar.gz | 5.2 kB | Without provenance | Details |
Release files / django-goodforms-0.2.1.tar.gz
| Download URL | django-goodforms-0.2.1.tar.gz |
|---|---|
| Size | 5.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d857de312ef118014161e147ca2abc67ba6c1bb36d203eff9c86f8472d7c479d
|
|
BLAKE2b-256 checksum How to use checksums |
bf7a250f7d63eae65dd77e931f9a8a4299398013b971801b61179d2d904bb699
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for django-goodforms 0.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.