Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8898835
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T00:42:44+00:00 2026-06-15T00:42:44+00:00

I’m using standard Django Model Forms which are then used in HTML templates for

  • 0

I’m using standard Django Model Forms which are then used in HTML templates for an application system we’re currently re-jigging.

The tricky bit (for me at least) is one step in the process which dynamically adds additional forms to the HTML using a jQuery plugin called “SheepIt” and I’m wondering how all the form data can be easily collected in the related view.

The SheepIt bit:

$(document).ready(function() {   
        var sheepItForm = $('#sheepItForm').sheepIt({
            separator: '',
            allowRemoveLast: true,
            allowRemoveCurrent: true,
            allowRemoveAll: false,
            allowAdd: true,
            allowAddN: false,
            minFormsCount: 1,
            iniFormsCount: 1
        });

    });

Template code:

<div id="entry_form">
<form method="post" enctype="multipart/form-data" action="/enter/2/" id="sheepItForm">
    <fieldset id="sheepItForm_template">
                <a id="sheepItForm_remove_current">X</a>
                <div class="select">{{ form.select }}</div>
                <div class="text">{{ form.text }}</div>
                <div class="upload">{{ form.upload }}</div>
    </fieldset>

     <div id="sheepItForm_noforms_template">No Entries</div>

     <div id="sheepItForm_controls">
         <div id="sheepItForm_add"><a><strong>+</strong> Add Another Entry</a></div>
     </div> 

{{ formset.management_form }}
<input type="submit" value="Proceed to Payment"> 
</form></div>

The above outputs a little form with buttons to add and remove clones of the form using the SheepIt plugin.

Normally, we would collect the form data with something like:

form_data = request.POST.copy()

Or similar. Should I just iterate over everything collected in the post data or is there a better perhaps ‘pythonic’ way of handling these little clones? Perhaps gathering them into a formset then doing something similar to:

for f in formset.forms:
    if f.is_valid():
        f.save()

Edit:
And here’s some of the views code that I’m currently chopping and changing:

    form = EntryForm_2_set.form()
    template_dict['form'] = form
    if request.method == 'POST':
        # from forms.py: EntryForm_2_set = forms.formsets.formset_factory(EntryForm_2, extra=0)
        formset = EntryForm_2_set(request.POST)
        if formset.is_valid():
            for f in formset.forms:
                if f.is_valid():
                    f.save()
            entry_url = reverse('entry-stage',kwargs={'stage':3}) 
            return HttpResponseRedirect(entry_url)
    else:
        formset = EntryForm_2_set()
        template_dict['formset'] = formset
    return render_to_response('submission-stage-two.html', template_dict, RequestContext(request)) 

Any ideas guys?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T00:42:46+00:00Added an answer on June 15, 2026 at 12:42 am

    Managed to sort it out myself eventually.

    Only thing that remains is filling the forms upon re-entry.

    The thing that I was missing before was the implementation of the formset factory with its flexibility. If there’s a more elegant solution I’d be interested to hear suggestions for future updates.

    Cheers guys.


    View code:

    # Create the formset factory with an initial form (extra=1)
    EntryForm_2Set = formset_factory(EntryForm_2,extra=1)
    if request.method == 'POST':
        formset = EntryForm_2Set(request.POST,request.FILES)
        if formset.is_valid():            
            instances = []
            for f in formset.forms:
                # get the new applicant instance
                inst = f.save()
                instances.append(inst)
            for i in instances:
                # amend the applicant instance
                i.applicant = request.session['applicant']
                i.save()
            num_entered = formset.total_form_count()
            entry_url = reverse(...) # some reversal 
            return HttpResponseRedirect(entry_url)
    else:
        formset = EntryForm_2Set()
    template_dict['formset'] = formset
    return render_to_response('submission-stage-two.html', template_dict, RequestContext(request)) 
    

    Template code:

    <div id="entry_form">
    <form method="post" enctype="multipart/form-data" action="/enter/2/" id="sheepItForm">
    
        {% for form in formset.forms %}            
                <fieldset id="sheepItForm_template">
                    <a id="sheepItForm_remove_current">X</a>
                    <div class="select">{{ form.select }}</div>
                    <div class="text">{{ form.text }}</div>
                    <div class="upload">{{ form.upload }}</div>
                </fieldset>
        {% endfor %}
    
      <div id="sheepItForm_controls">
        <div id="sheepItForm_add"><a ><strong>+</strong> Add Another</a></div>
      </div> 
    
      {{formset.management_form }}
      <input type="submit" value="Proceed"> 
    

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I have thousands of HTML files to process using Groovy/Java and I need to
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I am reading a book about Javascript and jQuery and using one of the
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am trying to understand how to use SyndicationItem to display feed which is
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.