Move search templates

This commit is contained in:
Matthias Portzel 2022-05-03 13:31:01 -04:00
parent 98e2aa29ba
commit d3345dc67f
5 changed files with 13 additions and 10 deletions

View File

@ -2,7 +2,7 @@ from haystack import indexes
from .models import Thought
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")
def get_model(self):

View File

@ -13,6 +13,10 @@ from .models import Thought, ThoughtForm, ALLOWED_MEDIA_TYPES
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):
authenticated = False
try:
@ -166,3 +170,10 @@ def about(request):
return render(request, "thoughts/about.html", {
"authenticated": check_authenticated(request)
})
search = search_view_factory(
template="thoughts/search/search.html",
view_class=SearchView,
form_class=SearchForm,
searchqueryset=SearchQuerySet().order_by("-posted")
)

View File

@ -5,19 +5,11 @@ from thoughts import views
from thoughts.feed import MainFeed
from whispermaphone import settings
from haystack.views import SearchView, search_view_factory
from haystack.query import SearchQuerySet
from haystack.forms import SearchForm
urlpatterns = [
path("", views.index, name="index"),
path("about", views.about, name="about"),
path("login", views.login, name="login"),
path("post", views.post, name="post"),
path("feed", MainFeed()),
path("search", search_view_factory(
view_class=SearchView,
form_class=SearchForm,
searchqueryset=SearchQuerySet().order_by("-posted")
), name="thoughts_search")
path("search", views.search, name="thoughts_search")
] + (static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) if settings.DEBUG else [])