Skip to content

A jQuery plugin that allows you dynamically add new forms to a rendered django formset.

License

Notifications You must be signed in to change notification settings

DallasMorningNews/django-dynamic-formsets

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

63 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

django-dynamic-formsets

A lightweight plugin for managing Django formsets with jQuery.

About this plugin

This jQuery plugin helps you create more usable Django formsets by allowing clients to add and remove forms on the client-side.

It was primarily developed by Stanislaus Madueke, and re-packaged as a static Django app (with a couple shiny new enhancements and more docs) by The Dallas Morning News.

This version of this plugin (like its predecessor) is available under the BSD License.


Getting started

  1. Download this repo or install from PyPI:
```bash
pip install django-dynamic-formsets
```
  1. Then add dynamic_formsets to your INSTALLED_APPS setting and run python manage.py collectstatic.

  2. You can now make your formsets dynamic by adding the following lines to a template:

```Django
{% load static %}

...

{% comment %}
    (Your templated DOM here, possibly something like this:)
{% endcomment %}

<form id="my-form" method="post" action="">
    {% csrf_token %}
    {{ formset.media }}
    {% for form in formset %}
        <div class="individual-form">
            {{ form.as_p }}
        </div>
    {% endfor %}
</form>

...

<script src="{% static "dynamic_formsets/jquery.formset.js" %}" type="text/javascript"> </script>

<script type="text/javascript">
    $('.individual-form').formset();
</script>
```

Configuration

Once you've followed steps 1 to 3 above, you're ready to customize the formset-handling javascript that's now on your page.

Detailed information about all the settings you can change in the javascript will be added to this repo very soon.

About

A jQuery plugin that allows you dynamically add new forms to a rendered django formset.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 89.4%
  • Python 10.6%