Hi I'm a newbie to Django. I'm trying to implement a search feature like this.
query_results = Shops.objects.filter\
(Q(shop_name__icontains=search_text)\
|Q(state__state_name__icontains=search_text)\
|Q(city__city_name__icontains=search_text)).distinct()
I would like to search Shops
based on the shop_name, state_name
and city_name
. State and city fields are foreign keys.
For some 'Shops' state
andcity
are null. However, shop_name
contains the search_text
. So I'm not getting those 'Shops
' by running this query.
Any help on this is appreciated.