Django search fields in multiple models
One solution is to query all the models # Look up Q objects for combining different fields in a single query from django.db.models import Q people = Person.objects.filter(Q(first_name__contains=query) | Q(last_name__contains=query) restaurants = Restaurant.objects.filter(restaurant_name__contains=query) pizzas = Pizza.objects.filter(pizza_name__contains=query) Then combine the results, if you want from itertools import chain results = chain(people, restaurants, pizzas) Ok, sure, here’s … Read more