Giter Site home page Giter Site logo

django-select-by's Introduction

django-select-by [This project is under development]

Description

Project, which brings a widget, which has the function of loading a select list from another select list.

Requirements

  1. This project was made for Django projects.
  2. The two fields involved must be linked to by forekeys.

Step by step

  1. To install you should use the command pip install django_select_by
  2. In your form.py file you must import the django_select_by lib and used in the field to be populated, it must be of type ModelChoiceField using the SelectBy widget (select_by = 'bank') passing the parent.
fromt django_select_by.widget import SelectBy

class MyForm(forms.Form):
   
    banco = forms.ModelChoiceField(label='Banco', required=CADASTRAL, widget=forms.Select(),
                                   queryset=Banco.objects.all())
    agencia = forms.ModelChoiceField(label='Agência', required=CADASTRAL, widget=SelectBy(select_by='banco'),
                                     queryset=Agencia.objects.all())
  1. In your template you must include the file select_by.js and use in your change method of the parent field the select_by method
{% include 'django_select_by/select_by.html' %}

(function($)
{
    $('#id_banco').change(function()
    {
        var agencia = $('#id_agencia').val();

        if($(this).val() && $(this).val() > 0)
            select_by('id_agencia', $(this).val());

        $('#id_agencia').val(agencia);
    })
    .trigger('change');
})
(jQuery);

django-select-by's People

Contributors

davidlso avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.