Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

339
Views
Django-dynamic-formset - only one select box works

I'm using Django-dynamic-formset to create template that adds formset when I click add button

On my formset there are two fields, one is CharField with choice_option and the other is CharField

When I click add button it adds formset properly and all my second field ( CharField with no choice_option) works well

However on my first field(CharField with choice_option), only the first select box works, and when I click the another select box below, the first select box is selected This is what happens when I click 2nd or below select box How can I make every select box work properly?

my code is like this which I followed https://github.com/elo80ka/django-dynamic-formset/blob/master/docs/usage.rst

Thanks in advance

<form>
    <table id="id_orders_table" border="0" cellpadding="0" cellspacing="0">
        <tbody>
            {% for inventory_form in inventory_formset %}
            <tr>
                <td>
                    {% if inventory_form.instance.pk %}{{ inventory_form.DELETE }}{% endif %} {{ inventory_form.inventory_type }}
                </td>
                <td>{{ inventory_form.inventory_description }}</td>
            </tr>
            {% endfor %}
        </tbody>
    </table>
    {{ inventory_formset.management_form }}

    <input type="submit" value="submit" />
</form>

<script src="{% static 'js/jquery.formset.js'%}"></script>
<script type="text/javascript">
    $(function() {
        $('#id_orders_table').formset({
            prefix: '{{ inventory_formset.prefix }}'
        });
    })
</script>
over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

if you are using materilizecss it will work. Or any cssframework. just find the way to initialize the select box. And create a function to initialize the select and call it on everytime when you add new row in formset. it can done by passing that function to fomset.which i mentioned below

function initialize_select(){
    $('select').material_select();

    }

    $(function() {
            $('#id_orders_table').formset({
                'prefix': '{{ inventory_formset.prefix }}',
                'added':initialize_select
            });
        })
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!