[Answered ]-How to run _icontains method on a foreignkey field in django

1👍

Well icontains doesn’t work with relationships but with field of the related model:

searched_pending_orders = orders.filter(user__username__icontains=search_query)

Will works perfectly.

Leave a comment