Skip to content

Kagiso-Future-Media/kagiso_smart_404

Repository files navigation

Codeship Status for Kagiso-Future-Media/kagiso_smart_404 codecov.io

kagiso_smart_404

Recommend similar pages if a given page is not found.

If a page is not found, looks up the pages in the database and returns any page with a similarly spelt slug, using trigrams for matching

Installation

pip install kagiso_smart_404

Add kagiso_smart_404 to your INSTALLED_APPS in your settings.py.

python manage.py migrate

Add the following to urls.py: handler404 = 'kagiso_smart_404.views.not_found

Sample 404 Page

{% extends "core/base.html" %}
{% load staticfiles %}
{% load wagtailcore_tags %}
{% load core_tags %}

{% block title %}404 error{% endblock %}

{% block body_class %}template-404{% endblock %}

{% block content %}
  <section class="error-page-wrapper error-404">
    <div class="error-message-block">
      <h1 class="error-title">404 Error</h1>
      <h4 class="error-subtitle">frequency not found</h4>
      {% if suggested_page %}
      <p>Were you looking for
        <a style="color: white; text-decoration: underline" href="{{ suggested_page.tracking_url }}">
          {{ suggested_page.title }}?
        </a>
      </p>
      {% else %}
        <p>The page you were looking for could not be found.</p>
      {% endif %}
    </div>
  </section>

{% endblock %}

Metrics Tracking via Librato

Add the following to your settings.py's MIDDLEWARE_CLASSES:

'kagiso_smart_404.middleware.SmartRedirectMetricsMiddleware',

Running the tests

py.test

About

Recommend similar Wagtail pages if a given page is not found.

Resources

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  

Languages