Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

352
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda