This app provides features a form class dynamic, both on the client and server side. For example if you want a field to be remove if another field has a particular value or to filter choices based on a set conditions. The demo is automatically updated when a commit is tested on master.
Pypy, Python 2.7, 3.4, Django 1.8+ are supported.
Example
For example, if your form should allow support only if linux is selected:
from ddf import shortcuts as ddf
class TestForm(ddf.FormMixin, forms.Form):
platform = forms.ChoiceField(choices=(
('Linux', 'Linux'),
('Windows', 'Windows'),
))
service = forms.ChoiceField(choices=(
('Format', 'Format'),
('Support', 'Support')
))
# Remove the 'Support' choice from the 'service' field if 'platform'
# value is 'Windows':
_ddf = dict(
service=[
ddf.RemoveChoices(
['Support'],
ddf.ValueIs('platform', 'Windows'),
)
]
)
In this example, we create a configuration field and add the RemoveChoices action to the service field, with the condition that the platform field value is Windows.
The configuration field is able to render the configuration as a JSON dict, with the form prefix it’s being rendered with. Then, the equivalent of each Action and Condition objects are instanciated in JavaScript, allowing dynamic user experience.
A configuration is structured as such: for each field, you may add a list of actions, for each action a list of conditions. When the user changes a field, each action’s conditions are evaluated and if they all pass then the action is applied, otherwise it is unapplied. Possibilities are huge here.
Dual-license
It is released with the Creative Commons Attribution-NonCommercial 3.0 Unported License, but a commercial license is available, please get in touch my username @ yourlabs.org if you are interrested.
Note that the money goes to YourLabs, a non-profit foundation to promote the role of hackers in the process of making our society more fair and free, while using their skills to develop local economy and give internet back to the people.
Status
The project is pretty young, but the basic building blocks are there. We should be able to add actions and conditions easily.
Why
We’ve been inventing this over and over again for years. The first time I invented this was in 2009 and honnestly my python, django and javascript skills were pretty weak back then. Since then, I’ve seen users asking this, paying me as a consultant for this, making pull requests to have this in a per-app basis. It’s about time we have a generic solution that works for all kinds of fields, and not just the ones of the apps we maintain.
Metadata
Release files for ddf 0.0.0
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 |
|---|---|---|---|---|
| ddf-0.0.0.tar.gz | 5.3 kB | Without provenance | Details for ddf-0.0.0.tar.gz |
Release files / ddf-0.0.0.tar.gz
| Download URL | ddf-0.0.0.tar.gz |
|---|---|
| Size | 5.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c5333ae01ecb349218580229933d4861addbd2b37371c49f670276a4c73be88b
|
|
BLAKE2b-256 checksum How to use checksums |
5076c27665c20e526c9eff51c2ec613e909b46a7eb6f4146e44aa9618c42e3ea
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for ddf 0.0.0
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.