Django Formsets with ECMAScript 6.
Project description
django-easy-formset
Django Formsets with ECMAScript 6
Installation
Installation is easy using pip and the only requirement is a recent version of Django.
python -m pip install django-easy-formset
Basic app configuration
Then to add the Django Easy Formset to your project add the app easy_formset
to
your INSTALLED_APPS
.
INSTALLED_APPS = [
# ...
"easy_formset",
]
How to use
Video
In template
{% load static %}
<head>
<link rel="stylesheet" href="{% static 'easy_formset/easy_formset.css' %}">
</head>
<body>
<div id="{{ formset.prefix }}">
{{ formset.management_form }}
<template formset-empty-form>
{{ formset.empty_form.as_p }}
<a formset-form-delete>Delete</a>
</template>
<div formset-forms>
{% for form in formset.forms %}
<div formset-form>
{{ form.as_p }}
<a formset-form-delete>Delete</a>
</div>
{% endfor %}
</div>
<button formset-add>Add Formset</button>
</div>
...
<script src="{% static 'easy_formset/easy_formset.js' %}"></script>
<script>
const formset = new Formset("{{ formset.prefix }}")
</script>
</body>
Custom undo element
// add one root element...
Formset.revertHTML = '<a href="#">Custom undo link...</a>'
const formset = new Formset("{{ formset.prefix }}")
Handle add/deleted events
document.addEventListener('formset:add', (event) => {
// access the form with event.detail.form
})
document.addEventListener('formset:deleted', (event) => {
// access the form with event.detail.form
})
Run tests
python -m pip -r requirements.txt
pytest
Run project test
python manage.py runserver
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for django-easy-formset-0.1.4.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8367dc565040ff04355cbc9aca9560549d9a54a9cdd41ff5cc5401c3f28b038c |
|
MD5 | c3ebbe436ce5bde4c367cb0ded4aa29b |
|
BLAKE2b-256 | eb3bbfd8dc489fc58ff3fb35aef5056b0a92e5363abf80c138265e22d97298bc |
Close
Hashes for django_easy_formset-0.1.4-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 028cc06f8e5962f166162477db66c5442b1845a0254dbabcf3b359c19c5f0c5d |
|
MD5 | 34fe916c957c4b2a3f40f1e5fb0652f3 |
|
BLAKE2b-256 | 8f19fc14d5f27f9e8641aab74826fb03a390eddc0b468b644371a614c53ab93c |