coral-formsets
Extensão para manipular o frontend usando Django FormSets.
Não tem dependência com outro framework/biblioteca javascript.
Documentation
Installation
Para instalar coral-formsets:
pip install coral-formsets
Adicione coral_formsets em INSTALLED_APPS:
INSTALLED_APPS = [
# other apps
"coral_formsets",
]
Usage
No seu html adicione o js como no exemplo abaixo.
Nesse exeplo yourapp/form.html é um arquivo referente ao template do seu form, isso garante mais clareza ao seu código:
<!-- yourapp/form.html -->
<div data-form>
<div style="display: none">{{ form.DELETE }}{{ form.id }}</div>
{{ form.as_p }}
<button data-delete>
delete form
</button>
</div>
<!-- yourapp/view.html -->
{% load static coral_formset_tags %}
<!DOCTYPE html>
<html>
<body>
<div data-formset>
{% render_empty_form_template 'yourapp/form.html' formset as empty_form %}
{{ formset.management_form }}
<div data-body>
{% for form in formset %}
{% include 'yourapp/form.html' with form=form %}
{% endfor %}
</div>
<button class="formset"
data-empty-form="{{ empty_form }}"
data-prefix="{{ formset.prefix }}">
Add form
</button>
</div>
<script src="{% static 'coral_formsets/js/FormSet.js' %}"></script>
<script>
document.querySelectorAll('.formset').forEach(el => {
new window.coral.FormSet(el);
});
</script>
</body>
</html>
A templatetag render_empty_form_template irá transformar o seu formset.empty_form em texto, para depois fazer a inserção do novo form via javascript.
Metadata
Release files for coral-formsets 0.1.2
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 |
|---|---|---|---|---|
| coral-formsets-0.1.2.tar.gz | 17.1 kB | Without provenance | Details for coral-formsets-0.1.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| coral_formsets-0.1.2-py3-none-any.whl | Python 3 | none | any | Details for coral_formsets-0.1.2-py3-none-any.whl |
Total release size: 34.4 kB
Release files / coral-formsets-0.1.2.tar.gz
| Download URL | coral-formsets-0.1.2.tar.gz |
|---|---|
| Size | 17.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
98ae417e935f5cafd15ddff20c79292b86035b571bc5ed9640e1f7d117457ea9
|
|
BLAKE2b-256 checksum How to use checksums |
9e17fbe4263fd85234567a9cdfb50aa4b215fade9b9b8bcb5076918f5f115168
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.12 CPython/3.9.5 Linux/5.11.0-43-generic
|
Release files / coral_formsets-0.1.2-py3-none-any.whl
| Download URL | coral_formsets-0.1.2-py3-none-any.whl |
|---|---|
| Size | 17.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
23e945dbb1c24ba5ac1ffede84fe51fe8a4e685aeebfe761070591cd51f1f803
|
|
BLAKE2b-256 checksum How to use checksums |
e064b7d5a142c8616202a393c7a87dbf5281087971eb14f8dd3a69bb3e993b50
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.12 CPython/3.9.5 Linux/5.11.0-43-generic
|
Security for coral-formsets 0.1.2
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.