Russell,

You are absolutely correct -- Django does not allow Q objects for the widgets ManyToManyRawIdWidget and ForeignKeyRawIdWidget. I don't exactly know why this limitation is there, however it was recently documented by @Daniele Procida at 79cc6669. As you can see, his changes to the Django documentation for limit_choices_to specify this limitation.

So this is a limitation that exists regardless of whether limit_choices_to can be a callable or not. In other words, I don't think it's a new limitation I am introducing in this pull request.

Background: The methods base_url_parameters() as well as url_params_from_lookup_dict() are only invoked when these widget types are used. Use of these widgets does not support using ``Q`` objects for limit_choices_to, I believe perhaps because they involve raw ids.

I don't know what the solution to this problem is, as it's probably hard to translate a ``Q`` object into a set of key-value parameters (see url_params_from_lookup_dict() function for example). But I believe solving this problem is beyond the scope of this ticket. What do you think?