[Answered ]-How to initialize a formset with dynamic number of data entries

2👍

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)
👤Rohan

Leave a comment