VariableDoesNotExist while rendering: Failed lookup for key [object]
<p>I am using django-haystack and elasticsearch on my Ubuntu server and finding that certain search queries just raise an error page, and I have no idea why this is happening..
Any help appreciated! :)</p>

<p>model.py : </p>

<pre><code>class EnActress(models.Model):
    name = models.CharField(max_length=100, null=True)
    image_urls = models.CharField(max_length=200)
    images = models.TextField(null=True)
    actress_image = models.TextField(null=True)


class EnMovielist(models.Model):
    content_ID = models.CharField(max_length=30)
    release_date = models.CharField(max_length=30)
    running_time = models.CharField(max_length=10)
    actress = models.CharField(max_length=300)
    series = models.CharField(max_length=30)
    director = models.CharField(max_length=30)
    label = models.CharField(max_length=30)
    image_urls = models.CharField(max_length=200, null=True)
    images = models.TextField(null=True)
    image_paths = models.TextField(null=True)
</code></pre>

<p>search.indexes.py : </p>

<pre><code> class EnActressIndex(indexes.SearchIndex, indexes.Indexable):
         text = indexes.EdgeNgramField(document=True, use_template=True)
         en_name = indexes.CharField(model_attr='name')

         def get_model(self):
             return EnActress
         def index_queryset(self, using=None):
             return self.get_model().objects.all()

 class EnMovielistIndex(indexes.SearchIndex, indexes.Indexable):
      text = indexes.EdgeNgramField(document=True, use_template=True)
      content_ID = indexes.CharField(model_attr='content_ID')
      release_date = indexes.CharField(model_attr='release_date')
      actress = indexes.CharField(model_attr='actress')
      label = indexes.CharField(model_attr='label')

      def get_model(self):
          return EnMovielist

      def index_queryset(self, using=None):
          return self.get_model().objects.all()
</code></pre>

<p>This is an Error massage in Django</p>

<pre><code>VariableDoesNotExist at /search/
Failed lookup for key [actress_image] in 'EnMovielist object'


 Failed lookup for key [%s] in %r
 In template /home/ubuntu/venv/avdict/dmmactress/templates/search/search.html, error at line 122

 112                {% load staticfiles %}
 113                &lt;table class="table table-striped table-hover"                            cellspacing="0" id='result_table'&gt;
 114                    &lt;thead&gt;
 115                        &lt;tr&gt;
 116                            &lt;th&gt;phto&lt;/th&gt;
 117                            &lt;th&gt;name&lt;/th&gt;
 118                        &lt;/tr&gt;
 119                    &lt;/thead&gt;
 120                    &lt;tbody&gt;
 121                        &lt;tr class="active"&gt;
 122                            {% with   image='enActress/'|add:result.object.actress_image %}
 123                            &lt;td&gt;&lt;img src="{% static image %}" class="img-circle" class="img-responsive"  alt="{{result.object.name}}"&gt;&lt;/td&gt;
 124                            &lt;td&gt;{{ result.object.name }}&lt;/td&gt;
 125                            {% endwith %}
 126                        &lt;/tr&gt;
 127    
 128                    &lt;/tbody&gt;
 129                &lt;/table&gt;
 130                {% empty %}
 131                    &lt;p&gt;no results.&lt;/p&gt;
 132                {% endfor %}


enactress_text.txt file : 

     {{ object.name}}
     {{ object.actress_image }}

 enmovielist_text.txt file :

     {{ object.content_ID }}
     {{ object.image_paths }}
     {{ object.release_date }}
     {{ object.running_time }}
     {{ object.actress }}
     {{ object.series }}
     {{ object.director }}
     {{ object.label }}
</code></pre>

<pre><code>Failed lookup for key [actress_image] in 'EnMovielist object'
</code></pre>

<p>This means you are looking up the <code>actress_image</code> value of an <code>EnMovielist</code> object.</p>

<p>What you are presumably trying to do requires <code>result.object</code> to be an instance of <code>EnActress</code>.</p>

python django elasticsearch