Drop in dynamic formsets in admin

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
{% extends "admin/change_form.html" %}
{% load i18n admin_modify adminmedia %}
{% block extrahead %}
{{ block.super }}
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js" ></script>
<script type="text/javascript">
  // Define this so we don't have to bother with the admin jsi18n stuff:
  function gettext(msgid) { return msgid; }

  $(function() {
      $('.inline-related tbody tr').formset({
      prefix: 'MODEL_set',
      addText: 'Add',
      deleteText: 'Delete',
  });
});
</script>
<style type="text/css">
  .add-row {
      padding-left:18px;
      background:url({% admin_media_prefix %}img/admin/icon_addlink.gif) no-repeat left center;
  }
  .delete-row {
      float:right;
      display:block;
      padding-left:18px;
      background:url({% admin_media_prefix %}img/admin/icon_deletelink.gif) no-repeat left center;
  }
<style>{% endblock %}

More like this

  1. Dynamically adding forms to a formset with jQuery by elo80ka 4 years, 2 months ago
  2. Complex Formsets, Redux by smagala 3 years, 3 months ago
  3. MPTTModelAdmin by anentropic 3 years, 7 months ago
  4. enani by andisthermal 2 years, 4 months ago
  5. Complex Formsets by smagala 4 years, 5 months ago

Comments

(Forgotten your password?)