Move search templates
This commit is contained in:
parent
98e2aa29ba
commit
d3345dc67f
|
@ -2,7 +2,7 @@ from haystack import indexes
|
||||||
from .models import Thought
|
from .models import Thought
|
||||||
|
|
||||||
class ThoughtIndex(indexes.SearchIndex, indexes.Indexable):
|
class ThoughtIndex(indexes.SearchIndex, indexes.Indexable):
|
||||||
text = indexes.CharField(document=True, use_template=True, template_name="search/indexes/thoughts/thought_text.txt")
|
text = indexes.CharField(document=True, use_template=True, template_name="thoughts/search/thought_text.txt")
|
||||||
posted = indexes.DateTimeField(model_attr="posted")
|
posted = indexes.DateTimeField(model_attr="posted")
|
||||||
|
|
||||||
def get_model(self):
|
def get_model(self):
|
||||||
|
|
|
@ -13,6 +13,10 @@ from .models import Thought, ThoughtForm, ALLOWED_MEDIA_TYPES
|
||||||
|
|
||||||
from .pagination import get_all_pages, get_page_slug
|
from .pagination import get_all_pages, get_page_slug
|
||||||
|
|
||||||
|
from haystack.views import SearchView, search_view_factory
|
||||||
|
from haystack.query import SearchQuerySet
|
||||||
|
from haystack.forms import SearchForm
|
||||||
|
|
||||||
def check_authenticated(request):
|
def check_authenticated(request):
|
||||||
authenticated = False
|
authenticated = False
|
||||||
try:
|
try:
|
||||||
|
@ -166,3 +170,10 @@ def about(request):
|
||||||
return render(request, "thoughts/about.html", {
|
return render(request, "thoughts/about.html", {
|
||||||
"authenticated": check_authenticated(request)
|
"authenticated": check_authenticated(request)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
search = search_view_factory(
|
||||||
|
template="thoughts/search/search.html",
|
||||||
|
view_class=SearchView,
|
||||||
|
form_class=SearchForm,
|
||||||
|
searchqueryset=SearchQuerySet().order_by("-posted")
|
||||||
|
)
|
||||||
|
|
|
@ -5,19 +5,11 @@ from thoughts import views
|
||||||
from thoughts.feed import MainFeed
|
from thoughts.feed import MainFeed
|
||||||
from whispermaphone import settings
|
from whispermaphone import settings
|
||||||
|
|
||||||
from haystack.views import SearchView, search_view_factory
|
|
||||||
from haystack.query import SearchQuerySet
|
|
||||||
from haystack.forms import SearchForm
|
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
path("", views.index, name="index"),
|
path("", views.index, name="index"),
|
||||||
path("about", views.about, name="about"),
|
path("about", views.about, name="about"),
|
||||||
path("login", views.login, name="login"),
|
path("login", views.login, name="login"),
|
||||||
path("post", views.post, name="post"),
|
path("post", views.post, name="post"),
|
||||||
path("feed", MainFeed()),
|
path("feed", MainFeed()),
|
||||||
path("search", search_view_factory(
|
path("search", views.search, name="thoughts_search")
|
||||||
view_class=SearchView,
|
|
||||||
form_class=SearchForm,
|
|
||||||
searchqueryset=SearchQuerySet().order_by("-posted")
|
|
||||||
), name="thoughts_search")
|
|
||||||
] + (static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) if settings.DEBUG else [])
|
] + (static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) if settings.DEBUG else [])
|
||||||
|
|
Loading…
Reference in New Issue