[Answered ]-Filtering a list of values in Django admin field, based on a previous field value selection

2👍

That app can help, i think (Django application to handle chained model fields) – https://github.com/digi604/django-smart-selects

link in pypi – https://pypi.python.org/pypi/django-smart-selects/

👤ndpu

0👍

If you are editing the profile, you can write a filter for the clients field with “formfield_for_manytomany” https://docs.djangoproject.com/en/dev/ref/contrib/admin/#django.contrib.admin.ModelAdmin.formfield_for_manytomany or “formfield_for_choice_field”.

But for creating a profile it’s only possible to change the client list with javascript afaik. Which can be a tricky thing on the admin forms.

Why do you not just select the clients and omit the formfield for the agency? You could validate the selection afterwards with a validator.

👤mbo

Leave a comment