When using model admin, if you have search_fields, and one of the fields is a foreign key, it raises the subject error:
Unsupported lookup 'icontains' for ForeignKey or join on the field not permitted.
Steps to Reproduce
Add FieldPanels to a Django model that has at least one foreignkey:
Add wagtail_hooks.py or edit it. Add search_fields and include the foreign key.
Make sure the wagtail_hooks are referenced as ModelAdmin or ModelAdminGroup.
Go to your website to the admin section for that model
Add 'something' to the "search" box and click the search button.
Witness the error
Any other relevant information. For example, why do you consider this a bug and what did you expect to happen instead?
Because it should be warned or considered in Wagtail, or consider in documentation how to refer to the foreign key str representation or an attribute of the foreign key.
I have confirmed that this issue can be reproduced as described on a fresh Wagtail project: (yes / no) No.
Technical details
Python version: Run python --version. 3.11.3
Django version: Look in your requirements.txt, or run pip show django | grep Version. 4.2.1
Wagtail version: Look at the bottom of the Settings menu in the Wagtail admin, or run pip show wagtail | grep Version:. 5.0
Issue Summary
When using model admin, if you have search_fields, and one of the fields is a foreign key, it raises the subject error:
Steps to Reproduce
Any other relevant information. For example, why do you consider this a bug and what did you expect to happen instead? Because it should be warned or considered in Wagtail, or consider in documentation how to refer to the foreign key str representation or an attribute of the foreign key.
Technical details
python --version
. 3.11.3pip show django | grep Version
. 4.2.1pip show wagtail | grep Version:
. 5.0