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.3.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6ea9fd891c0b88e9537fd97b2e20f06fc1afb2a514c1c1d9abb7e11eac448e1e |
|
MD5 | 6b4851847d4128886cb6fde78c7472c0 |
|
BLAKE2b-256 | c07cd83c74f49f9f26e14d8a7f3ff753957c0928b5f4d607b994ab8c45ec0b15 |
Close
Hashes for django_easy_formset-0.1.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 09734bcf9f0ca555e3174f2312da930e26f4f5fa30d1ed489aaf8dc8451d82ad |
|
MD5 | 3800ba7ad6df30be32e40f81062647fc |
|
BLAKE2b-256 | e1952c1a4ab4089e3fc5c4cb7550268348b266033a6f49cc12e590a9e0b44f3c |