Django Param
Django Param provides the ParamForm class which translates a param class into a native Django Form.
Quick start
Add 'colorfield', 'django_select2', 'django_param' and 'django.forms' to your INSTALLED_APPS setting like this:
```python
INSTALLED_APPS = [
...
'colorfield',
'django_select2',
'django_param',
]
```
Usage
# Specify your param class
class MyParam(param.Parameterized):
probability = param.Number(0.5, bounds=(0, 1), doc="Probability that...")
test_string = param.String(default="test string", doc="Your String")
my_param = MyParam()
# Initialize Django Form
form = ParamForm({'probability': 0.1, 'test_string': 'test_bound'}, param=my_param)
# Get data from request.POST
form = ParamForm(request.POST, param=my_param)
# To return param with values from request.POST
param = form.as_param()
Use form in template like a normal Django form:
- First you need to add the form media, you can include
{{ form.media }}in the head element of your page. - To add the form, simply use
{{ form }}
Supported param.Parameters
- Boolean
- Color
- CalendarDate
- DataFrame
- Date
- FileSelector
- ListSelector
- Magnitude
- MultiFileSelector
- NumericTuple
- ObjectSelector
- Range
- Selector
- String
- Tuple
- XYCoordinates
Custom Widgets
You can also override any default widget with your own custom widgets. For example:
widget_map = {
param.String:
lambda parameterized_object, parameter, name: forms.CharField(
initial=parameterized_object.inspect_value(name) or parameter.default,
widget=Textarea,
),
}
form = ParamForm(param=my_param, widget_map=widget_map)
Metadata
Release files for django-param 0.1.10
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 |
|---|---|---|---|---|
| django_param-0.1.10.tar.gz | 88.0 kB | Without provenance | Details for django_param-0.1.10.tar.gz |
Release files / django_param-0.1.10.tar.gz
| Download URL | django_param-0.1.10.tar.gz |
|---|---|
| Size | 88.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7067c2240e72e3e3b2f4be04650163599cb1a08977a41156333bae4f3bfce8a0
|
|
BLAKE2b-256 checksum How to use checksums |
bbabdddb76f75a643e172194cc531e634b76dc0f8c4cf277b9980a6fe099bffe
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.8.6
|
Security for django-param 0.1.10
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.