I am trying to add a haystack search to my base.html to include it globally on my site. These are errors though when I submit a search
I get:
Django-Haystack: the NoneType object does not have the _default_manager attribute
I added it to INSTALLED_APPS and my urls.py ../ manage.py rebuild_index works fine.
models.py:
class Site(models.Model): site_name = models.CharField(max_length=100, blank=False, null=False) site_manager = models.CharField(max_length=100, blank=False, null=False) address_1 = models.CharField(max_length=100, blank=False, null=False) address_2 = models.CharField(max_length=100, blank=True, null=True) address_3 = models.CharField(max_length=100, blank=True, null=True) town_city = models.CharField(max_length=100, verbose_name='Town/City') county = models.CharField(max_length=100, blank=False, null=False) postcode = models.CharField(max_length=100, blank=False, null=False) region = models.CharField(max_length=100, blank=True, null=True) tel = models.CharField(max_length=100, blank=False, null=False) email = models.EmailField(max_length=100, blank=False, null=False) creation = models.DateField(auto_now_add=True) last_modified = models.DateField(auto_now=True) def __unicode__(self): return self.site_name
SiteIndex.py:
class SiteIndex(indexes.SearchIndex, indexes.Indexable): text = indexes.CharField(document=True, use_template=True) site_name = indexes.CharField(model_attr='site_name') site_manager = indexes.CharField(model_attr='site_manager') address_1 = indexes.CharField(model_attr='address_1') address_2 = indexes.CharField(model_attr='address_2') address_3 = indexes.CharField(model_attr='address_3') town_city = indexes.CharField(model_attr='town_city') county = indexes.CharField(model_attr='county') postcode = indexes.CharField(model_attr='postcode') region = indexes.CharField(model_attr='region') tel = indexes.CharField(model_attr='tel') email = indexes.CharField(model_attr='email') creation = indexes.DateField(model_attr='creation') last_modified = indexes.DateField(model_attr='last_modified') def get_model(self): return Site def index_queryset(self, using=None): return self.get_model().objects.all()
site_text.txt:
{{ object.site_name }} {{ object.site_manager }} # ect
base.html
<form action="/search/" method="get"> <input type="text" name="q"> <input type="submit" value="Search"> </form>
UPDATE:
I noticed that if I upgrade to DJango 1.8. It works. Is there a problem with other versions of django uptodate?
Mantis
source share