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

  • Home
  • SEARCH
  • 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 9146743
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T10:49:10+00:00 2026-06-17T10:49:10+00:00

I have a ModelForm that users can submit to save information to a database.

  • 0

I have a ModelForm that users can submit to save information to a database. I want to extend it with a ModelFormset so that the user can view and submit the multiple of the same model forms with different information at the same time. However, my POST data isn’t binding to the ModelFormset, so the ModelFormset fails as invalid upon is_valid(). I see there is data associated with request.POST.copy(), it just

views.py

def create(request):
    if request.method == 'POST':
        post_data = request.POST.copy()
        print "POST DATA"
        print post_data
        for i in post_data:
            print i
        formSet = WorkOrder_Form(post_data)
        print "FORMSET"
        print formSet
        if formSet.is_valid():
            formSet.save()
        else:
            print 'INVALID'
        return HttpResponseRedirect('/Shelling/') 
    else:
        formSet = formset_factory(WorkOrder_Form, extra=1)
        return render_to_response('create.html',{'WorkOrder_Form':formSet}, context_instance=RequestContext(request))

template: (create.html)

{% load url from future %}
<a href="{% url 'index' %}"> Return to Index </a></li>
<br>
<br>
<form action="{% url 'create' %}" method="post"> {% csrf_token %}


{% for WorkOrder in WorkOrder_Form %}
    {{ WorkOrder.as_ul }}
    <br>
{% endfor %}

  • 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-17T10:49:11+00:00Added an answer on June 17, 2026 at 10:49 am

    You are using model forms, so you should use modelformset_factory instead of formset_factory. You can create the formset class outside of the create view. Then, you need to instantiate the formset in the GET and POST branches of your view.

    Putting it together, you have the following (untested, so there might be some typos!)

    WorkOrderFormSet = formset_factory(WorkOrder_Form, extra=1)
    
    def create(request):
        if request.method == 'POST':
            post_data = request.POST.copy()
            formset = WorkOrderFormSet(data=post_data, queryset=WorkOrder.objects.none())
            if formset.is_valid():
                formset.save()
            else:
                print 'INVALID'
            return HttpResponseRedirect('/Shelling/') 
        else:
            formset = WorkOrderFormSet(queryset=WorkOrder.objects.none())
            return render_to_response('create.html',{'formset':formset}, context_instance=RequestContext(request))
    

    And in the template:

    {% for form in formset %}
        {{ form.as_ul }}
    {% endfor %}
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to create a form where users can save their progress. I have
I have a ModelForm that I have created a view and template with to
I have a form on my Django site (made with ModelForm) where users can
General I have two kind of users, and one field (cluster) that I want
If you have 2 views, the first uses modelform that takes inputted information from
In a ModelForm, i have to test user permissions to let them filling the
I have a Django app where users submit orders for payment. Clearly, security is
I have a situation where a user can click a check box field, field_enable,
I have a modelform that will either create a new model or edit an
I am trying to make a view that allows a user to edit a

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.