If you need to override an autocomplete's behaviour based on its use in a django form, it is how I managed to do it.
Normally you would use formfield_for_foreignkey but when using autocomplete_fields
is not taken in account by django admin.
Note: this is not dynamic based based on the values in the form