--- /dev/null
+import datetime
+from haystack import indexes
+from .models import Lesson
+
+
+class LessonIndex(indexes.SearchIndex, indexes.Indexable):
+ text = indexes.CharField(document=True, use_template=True)
+
+ def get_model(self):
+ return Lesson
--- /dev/null
+{{ object.html_file.read|striptags }}
# Disable, if not using CAS.
'django_cas',
'sponsors',
+ 'haystack',
+
'django.contrib.auth',
'django.contrib.contenttypes',
--- /dev/null
+HAYSTACK_CONNECTIONS = {
+ 'default': {
+ 'ENGINE': 'haystack.backends.solr_backend.SolrEngine',
+ 'URL': 'http://127.0.0.1:8983/solr/edumed'
+ },
+}
<div id="tagline">Scenariusze zajęć, ćwiczenia, materiały</div>
<div id="search">
- <form action="">
+ <form action="{% url 'haystack_search' %}">
<input name="q" placeholder="szukaj" /><button><span>→</span></button>
</form>
</div>
--- /dev/null
+{% extends "base.html" %}
+
+{% block body %}
+ <h1>Wyszukiwanie</h1>
+
+ {% if query %}
+ {% for result in page.object_list %}
+ <p>
+ <a href="{{ result.object.get_absolute_url }}">{{ result.object.title }}</a>
+ </p>
+ {% empty %}
+ <p>Brak wyników.</p>
+ {% endfor %}
+
+ {% if page.has_previous or page.has_next %}
+ <div>
+ {% if page.has_previous %}<a href="?q={{ query }}&page={{ page.previous_page_number }}">{% endif %}« Poprzednie{% if page.has_previous %}</a>{% endif %}
+ |
+ {% if page.has_next %}<a href="?q={{ query }}&page={{ page.next_page_number }}">{% endif %}Następne »{% if page.has_next %}</a>{% endif %}
+ </div>
+ {% endif %}
+ {% else %}
+ <p>Brak wyników.</p>
+ {% endif %}
+{% endblock %}
# url(r'^i/', include('django.contrib.flatpages.urls')),
url(r'^i/(?P<url>.*)$', 'django.contrib.flatpages.views.flatpage',
name="info"),
+ url(r'^szukaj/', include('haystack.urls')),
)
# sponsors
pillow
django-sponsors
+
+-e git+https://github.com/toastdriven/django-haystack.git@61b377d97efd5390c60c5a37acd009b8e69eb2f3#egg=django-haystack
+pysolr>=2,<3