Django 5: Within the form, filter data with another field of the same form

This technique or method is typically referred to as “chained”, “cascade”, or “dependent” selects. (Those are the typical search terms you’d want to use when searching for this.)

Briefly, doing this involves some JavaScript on the page to catch the change event on the widget. That JavaScript then needs to call a view to get the updated list and update the second selection widget.

There are a couple of packages available to do this sort of thing, but I’m not sure how up-to-date or reliable they are. See GitHub - jazzband/django-smart-selects: chained and grouped selects for django forms as one such example.
Even if you don’t find this specific package to work with what you’re trying to do, the source code would give you some ideas on how to do this.

Also, I believe the Django-Select2 package can do this as well. (See Extra — Django-Select2 8.1.3.dev29+g7333018 documentation)