
{% load crispy_forms_tags i18n %}

{% block content %}
    <form method="get" action=".">
        {% crispy form %}

        {% if query %}
            <h3>Results</h3>

            {% for result in page.object_list %}
                <p>
                    {% if result.content_type == "media.image" %}
                        <a href="{{ result.object.url }}">{{ result.object }}</a>
                    {% else %}
                        <a href="{{ result.object.get_absolute_url }}">{{ result.object.title }}</a>
                    {% endif %}
                </p>
            {% empty %}
                <p>No results found.</p>
            {% endfor %}

            {% if page.has_previous or page.has_next %}
                <div>
                    {% if page.has_previous %}<a href="?q={{ query }}&amp;page={{ page.previous_page_number }}">{% endif %}&laquo; {% trans 'Previous' %}{% if page.has_previous %}</a>{% endif %}
                    |
                    {% if page.has_next %}<a href="?q={{ query }}&amp;page={{ page.next_page_number }}">{% endif %}{% trans 'Next' %} &raquo;{% if page.has_next %}</a>{% endif %}
                </div>
            {% endif %}
        {% else %}
            {# Show some example queries to run, maybe query syntax, something else? #}
        {% endif %}
    </form>
{% endblock %}