[Answered ]-Django: Dynamic inline forms with filter upon user selection

2👍

This likely can not be managed within the Django forms framework which is very limited in functionality. It allows you to use a filtered queryset for selections in a ModelChoiceDropDown (I think that’s the name) but filtering after a selection isn’t possible this way. Django’s forms are generated and sent as HTML which can not be made to filter without many modifications.

The way you would likely do this is to set up a REST interface (See Django Rest Framework or Django-Tastypie) and link your dropdowns to that using a front end framework of your choosing (I prefer Backbone.js, but there are many options). The idea being that once you select a service the subsequent dropdowns will add a filter to their requests to only show the Monitors that offer that service.

If you wish to keep using Django Forms you can, but you’ll need to extend the default fields to get this sort of functionality.

This is a fairly big rabbit hole and I don’t have any resources off the cuff to point you toward. But reading up about REST interfaces is a good start.

👤Don

Leave a comment