-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed a bizarre bug where backends may see a different site object th…
…an the rest of the application code. THIS REQUIRES SEARCH & REPLACING ALL INSTANCES OF `from haystack.sites import site` TO `from haystack import site`. No changes needed if you've been using `haystack.autodiscover()`.
- Loading branch information
1 parent
d2563c7
commit 95d40e4
Showing
21 changed files
with
108 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
from django.conf.urls.defaults import * | ||
|
||
import haystack | ||
haystack.autodiscover() | ||
|
||
urlpatterns = patterns('', | ||
(r'^search/', include('haystack.urls')), | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
from django.conf.urls.defaults import * | ||
|
||
from haystack import indexes | ||
from haystack import site | ||
from site_registration.models import Foo, Bar | ||
|
||
class FooIndex(indexes.SearchIndex): | ||
text = indexes.CharField(document=True, model_attr='body') | ||
|
||
site.register(Foo, FooIndex) | ||
site.register(Bar) | ||
|
||
urlpatterns = patterns('', | ||
(r'^search/', include('haystack.urls')), | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
from django.db import models | ||
|
||
|
||
class Foo(models.Model): | ||
title = models.CharField(max_length=255) | ||
body = models.TextField() | ||
|
||
def __unicode__(self): | ||
return self.title | ||
|
||
|
||
class Bar(models.Model): | ||
author = models.CharField(max_length=255) | ||
content = models.TextField() | ||
|
||
def __unicode__(self): | ||
return self.author |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
from haystack import indexes | ||
from haystack import site | ||
from site_registration.models import Foo, Bar | ||
|
||
|
||
class FooIndex(indexes.SearchIndex): | ||
text = indexes.CharField(document=True, model_attr='body') | ||
|
||
|
||
site.register(Foo, FooIndex) | ||
site.register(Bar) |
2 changes: 2 additions & 0 deletions
2
tests/site_registration/templates/search/indexes/bar_text.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
{{ object.title }} | ||
{{ object.body }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
from django.test import TestCase | ||
|
||
class ManualSiteRegistrationTestCase(TestCase): | ||
def test_registrations(self): | ||
from haystack import backend | ||
sb = backend.SearchBackend() | ||
self.assertEqual(len(sb.site.get_indexed_models()), 2) | ||
|
||
from haystack import site | ||
self.assertEqual(len(site.get_indexed_models()), 2) | ||
|
||
|
||
class AutoSiteRegistrationTestCase(TestCase): | ||
urls = 'site_registration.auto_urls' | ||
|
||
def test_registrations(self): | ||
from haystack import backend | ||
sb = backend.SearchBackend() | ||
self.assertEqual(len(sb.site.get_indexed_models()), 2) | ||
|
||
from haystack import site | ||
self.assertEqual(len(site.get_indexed_models()), 2) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import os | ||
from settings import * | ||
|
||
INSTALLED_APPS += [ | ||
'site_registration', | ||
] | ||
|
||
ROOT_URLCONF = 'site_registration.manual_urls' | ||
|
||
HAYSTACK_SEARCH_ENGINE = 'whoosh' | ||
HAYSTACK_WHOOSH_PATH = os.path.join('tmp', 'test_whoosh_query') | ||
HAYSTACK_INCLUDE_SPELLING = True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters