Django - Calling .object on a SearchQuerySet() returns None -


i've hit dead end django 1.9.5 project. im running haystack 2.4.1 , whoosh 2.7.4 search-engine. here poblem:

when accessing followng view:

def search_titles(request):     resources = searchqueryset().autocomplete(content_auto=request.post.get('search_text', ''))     return render_to_response('ajax_search.html', {'resources' : resources}) 

with ajax_search.html looking follows:

{% if resources.count > 0 %} {% resource in resources %}     <li>{{resource.object.title}} _ {{resource.object}}</li> {% endfor %} {% else %} <li>none show</li> {% endif %} 

the search works fine. depending on search exact amount of results should getting, @ line

<li>{{resource.object.title}} _ {{resource.object}}</li> 

they show as

  • _ none

(.object.title being blank , .object being none).

in case helps, here search_indexes.py:

class resourceindex(indexes.searchindex, indexes.indexable):     text = indexes.charfield(document=true, use_template=true)     published = indexes.datefield(model_attr='published')     content_auto = indexes.edgengramfield(model_attr='title')     def get_model(self): return resource     def index_queryset(self, using=none): return self.get_model().objects.all() 

and resource_text.txt:

{{object.title}} {{object.subtitle}} 

the resource-model looks this:

class resource(models.model):     authors = models.manytomanyfield(person, related_name='resources_authored')     title = models.charfield(max_length=300, unique=true)     subtitle = models.charfield(max_length=300, unique=true)     published = models.datefield('date published')      def __str__(self): return self.title     def get_absolute_url(self): return '/resources/%i/' % self.id     class meta:         ordering = ['-published', 'title']         get_latest_by = 'published' 

anybody got ideas why none-objects when calling .object on results in searchqueryset?


Comments

Popular posts from this blog

sequelize.js - Sequelize group by with association includes id -

android - Robolectric "INTERNET permission is required" -

java - Android raising EPERM (Operation not permitted) when attempting to send UDP packet after network connection -