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 8163291
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T18:59:08+00:00 2026-06-06T18:59:08+00:00

Im able to populate my formset with the elements of an array which is

  • 0

Im able to populate my formset with the elements of an array which is actuals_data only when i know the number of elements in the array prior to running my code, which is 12 for this code,but how to populate the formset from the array when i dont know the number of elements in the array prior to running my code, which comes in variable count.

my view is

def show_actuals(request):

Account_Number_in = request.session['account_number']
Year_in = request.session['year']
count = request.session['count']
actuals_data = request.session['actuals_to_show']
months = request.session['months']
show_actuals_formset = formset_factory(FetchActualsBox, extra=0)

formset = show_actuals_formset(initial=[{'Value': actuals_data[0]},
                    {'Value': actuals_data[1]},
                    {'Value': actuals_data[2]},
                    {'Value': actuals_data[3]},
                    {'Value': actuals_data[4]},
                    {'Value': actuals_data[5]},
                    {'Value': actuals_data[6]},
                    {'Value': actuals_data[7]},
                    {'Value': actuals_data[8]},
                    {'Value': actuals_data[9]},
                    {'Value': actuals_data[10]},
                    {'Value': actuals_data[11]},
                    ])



return render_to_response('ShowActualsData.html', {'formset' : formset , 'count' : count, 'actuals_data' : actuals_data , 'months' : months , 'Account_Number' : Account_Number_in , 'Year' : Year_in })
  • 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-06T18:59:09+00:00Added an answer on June 6, 2026 at 6:59 pm

    You can iterate and create list with given number of items.

    Sample code:

    def show_actuals(request):
    
        Account_Number_in = request.session['account_number']
        Year_in = request.session['year']
        count = request.session['count']
        actuals_data = request.session['actuals_to_show']
        months = request.session['months']
        show_actuals_formset = formset_factory(FetchActualsBox, extra=0)
        initial_list = []
        for data in actuals_data:
           initial_list.append({'value': data})
        formset = show_actuals_formset(initial=initial_list)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am able to get the current date, but I don't know how to
I'm trying to populate a multidimensional array (array with array elements) via Javascript or
I currently used a gridview and im able to populate something similar to this
I recently have just been able to populate my core data DB. I have
I want to define a class that is able to populate itself reading from
not able to get this, can someone help for this LINQ query? select col1,
I have a client that wanted their sales staff to be able to populate
I'm trying to populate a wxListCtrl but after trying various methods can't seem to
Currently I am able to populate my spinner two ways one way gives me
In Dojo 1.3 I was able to populate dojox.grid.DataGrid's cell with an <a href>

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.