Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

340
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda