Skip to main content

Django Formsets with ECMAScript 6.

Project description

django-easy-formset

Django Formsets with ECMAScript 6

Python tests Upload Python Package

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

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django-easy-formset-0.1.3.tar.gz (4.1 kB view details)

Uploaded Source

Built Distribution

django_easy_formset-0.1.3-py3-none-any.whl (4.5 kB view details)

Uploaded Python 3

File details

Details for the file django-easy-formset-0.1.3.tar.gz.

File metadata

  • Download URL: django-easy-formset-0.1.3.tar.gz
  • Upload date:
  • Size: 4.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.48.0 CPython/3.8.3

File hashes

Hashes for django-easy-formset-0.1.3.tar.gz
Algorithm Hash digest
SHA256 6ea9fd891c0b88e9537fd97b2e20f06fc1afb2a514c1c1d9abb7e11eac448e1e
MD5 6b4851847d4128886cb6fde78c7472c0
BLAKE2b-256 c07cd83c74f49f9f26e14d8a7f3ff753957c0928b5f4d607b994ab8c45ec0b15

See more details on using hashes here.

File details

Details for the file django_easy_formset-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: django_easy_formset-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 4.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.48.0 CPython/3.8.3

File hashes

Hashes for django_easy_formset-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 09734bcf9f0ca555e3174f2312da930e26f4f5fa30d1ed489aaf8dc8451d82ad
MD5 3800ba7ad6df30be32e40f81062647fc
BLAKE2b-256 e1952c1a4ab4089e3fc5c4cb7550268348b266033a6f49cc12e590a9e0b44f3c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page