title: How can I iterate over two or more template indexes with Haystack, Whoosh and Django
body: <p>I was reading the docs and some questions around here and couldn't understand how can I return a query that has fields indexed in two different classes. Let me put the code below:</p>
  
  <p>Here I have the classes:</p>
  
  <pre><code>class T031003Index(RealTimeSearchIndex):
  text = CharField(document=True, use_template=True)
  C003INST = IntegerField(model_attr='C003INST')
  C003CHCD = CharField(model_attr='C003CHCD')
  C003MTR = CharField(model_attr='C003MTR')
  C003RZSC = CharField(model_attr='C003RZSC')
  
  def index_queryset(self):
      return T031003.objects.all()
  
  def prepare(self, obj):
      self.prepared_data = super(T031003Index, self).prepare(obj)
      self.prepared_data['text'] = obj.C003CHCD
      return self.prepared_data
  
  site.register(T031003, T031003Index)
  </code></pre>
  
  <p>And the second one:</p>
  
  <pre><code>class T031002Index(RealTimeSearchIndex):
  text = CharField(document=True, use_template=True)
  C002USER = CharField(model_attr='C002USER')
  
  def index_queryset(self):
      return T031002.objects.all()
  
  def prepare(self, obj):
      self.prepared_data = super(T031002Index, self).prepare(obj)
      self.prepared_data['text'] = obj.C002USER
      return self.prepared_data
  site.register(T031002, T031002Index)
  </code></pre>
  
  <p>And I have two template indexes for each of them:</p>
  
  <p>T031003_text:</p>
  
  <pre><code>{{ object.C003INST }}
  {{ object.C003CHCD }}
  {{ object.C003MTR }}
  {{ object.C003RZSC }}
  </code></pre>
  
  <p>T031002_text:</p>
  
  <pre><code>{{ object.C002USER }}
  {{ object.C002INST }}
  </code></pre>
  
  <p>My template code:</p>
  
  <pre><code>{% if page.object_list %}    
  {% for object in page.object_list %}
      &lt;br&gt;
      &lt;li&gt;&lt;font class="font"&gt;
        {{ object.C003RZSC }}, {{ object.C003INST }}, {{ object.C003CHCD }}, {{ object.C003MTR }}, {{ object.C002USER }}
      &lt;/li&gt;
  {% endfor %}
  </code></pre>
  
  <p>My view:</p>
  
  <pre><code>def search(req):
  return SearchView(template='search.html')(req)
  </code></pre>
  
  <p>If I type in the search box a value from a field, let's say, that belongs to class T031002Index (like user = "vane"), it gives me the result:</p>
  
  <p>"None, None, None, None, vane"</p>
  
  <p>And, if I type a value from a field in class T031003Index, it gives me the result:</p>
  
  <p>"pencil, 1, school material, general, None"</p>
  
  <p>I have between these two classes in models.py a Foreign Key field, which is C002INST.</p>
  
  <p>Could you guys give me an explanation? It seems easy, but I can't figure it out by myself.</p>
  
  <p>Thanks in advance!</p>