change modelChoiceField queryset dynamically

Hi all,
I would like change modelChoiseField dinamically:

for example I have two modelChoiseFields:

assigned1Id=forms.ModelChoiceField(queryset=models.User.objects.all().filter(status=True),empty_label="Name")
assigned2Id=forms.ModelChoiceField(queryset=models.Properties.objects.all().filter(status=True),empty_label="Properties")

I would like that:

  1. if not User is selected, the second ModelChoiceField show all Properties
  2. if a User is selected in the first modelChoiceField, then the second modelChoiceField add a filter in real time in the queryset.

the same could occurs with some other inputs:
for example if a charInput contains a value, the queryset must filter properties list in the modelChoiceField adding conditions.

it is possible?
many thanks.

The useful term to look for is “dependent fields” or “chained fields”.

This guide might help How to Implement Dependent/Chained Dropdown List with Django

In addition to the excellent reference above, you might also want to check out the implementations at

Even if those packages don’t do exactly what you want, reading the source code to understand how they work can be very instructive.

Also, HTMX can be used as an implementation for this in the client as well, if you’re already using it.