Skip to main content

Django Formsets with ECMAScript 6.

Project description


Django Formsets with ECMAScript 6

Python tests Upload Python Package


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.

    # ...

How to use



In template

{% load static %}
  <link rel="stylesheet" href="{% static 'easy_formset/easy_formset.css' %}">
  <div id="{{ formset.prefix }}">
    {{ formset.management_form }}

    <template formset-empty-form>
      {{ formset.empty_form.as_p }}
      <a formset-form-delete>Delete</a>

    <div formset-forms>
      {% for form in formset.forms %}
        <div formset-form>
          {{ form.as_p }}
          <a formset-form-delete>Delete</a>
      {% endfor %}
    <button formset-add>Add Formset</button>
  <script src="{% static 'easy_formset/easy_formset.js' %}"></script>
    const formset = new Formset("{{ formset.prefix }}")

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

Run project test

python runserver

Project details

Download files

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

Files for django-easy-formset, version 0.1.3
Filename, size File type Python version Upload date Hashes
Filename, size django_easy_formset-0.1.3-py3-none-any.whl (4.5 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size django-easy-formset-0.1.3.tar.gz (4.1 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page