Index data from not related models in Django-Haystack Solr
<p>I have a model to which multiple other models point through foreign keys, like:</p>

<pre><code>class MainModel(models.Model):
    name=models.CharField(max_length=40)

class PointingModel1(models.Model):
    color=models.CharField(max_length=40)
    main_model=models.ForeignKey(MainModel)

class PointingModel2(models.Model):
    othername=models.CharField(max_length=40)
    main_model=models.ForeignKey(MainModel)
</code></pre>

<p>So I want to return the name of the MainModel by searching for color and othername fields in the PointingModels. Is there any way to do this?</p>

<p>It's easy.</p>

<pre><code>colors = PointingModel1.objects.filter(color='blue')
for color in colors:
    name = color.main_model.name
    # now you can put `name` to a list or something else
</code></pre>

python django solr