Code Monkey home page Code Monkey logo

chaineddropdown's Introduction

chaineddropdown

Two examples of chained dropdown [ForeingKey and ManyToMany] Using AJAX and Django 3.0

------YOU MUST PUT THE INFO IN DATABASE-----

Here I present two kind of examples for different situations.

  1. Person example: Who has to fill a form with the options 'Country' and 'City'
  2. File example: For those who need to download a file for a selecting a 'Subject' and a 'Teacher'

In both examples the steps to follow are:

Step 1) Create a CreateView (class) in Views.py --------> (PersonView and FileView)

Step 2) Create a function to call the chained dropdown (def) in Views.py --------> (load_cities and load_teachers)

Step 3) Indicate the urls for the CreateView and for the load functions in urls.py --------> (PersonView|FileView and load_cities|load_teachers)

Step 4) Create a form filtered for both cases in forms.py --------> (PersonForm and FileForm)

Step 5) Create a HTML for the dropdown load ---------> (dropdowncities.html and dropdownteachers.html)

Step 6) Create a HTML form in wich we will use AJAX to make the calls ---------> (person_example.html and file_example.html)

chaineddropdown's People

Contributors

showiz avatar

Watchers

 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.