Skip to main content

wagtail-showsimilar

Display similar items by field value from wagtail search results.

Screeen Shot

Quick Start

Installation

pip install wagtail-showsimilar

Setup

Add wagtailshowsimilar to your settings.py in the INSTALLED_APPS section:

INSTALLED_APPS = [
    ...
    'wagtailshowsimilar',
]

Add admin urls

from wagtailshowsimilar.urls import urlpatterns as showsimilar_admin_urls

urlpatterns = [
    ...
    path('admin/showsimilar/', include(showsimilar_admin_urls)),
    path('admin/', include(wagtailadmin_urls)),
    ...
]

ShowSimilarPanel

The model should be searchable to work with wagtail-showsimilar, All pages, images and documents are searchable by default in Wagtail.

Options

  • score_threshold (int/float) - Only score for matched results above this value will be listing. This field only works with Elasticsearch backend. (default: 20)
  • max_items (int) - Maximum number of listing items shown from search results. (default: 10)
from django.db import models

from wagtail.search import index
from wagtailshowsimilar.edit_handlers import ShowSimilarPanel

class BreadType(index.Indexed, models.Model):
    title = models.CharField(max_length=255)

    panels = [
        ShowSimilarPanel('title', score_threshold=5),
    ]

    search_fields = [index.SearchField('title', partial_match=True)]

You'll need to inherit from index.Indexed for custom models and add some search_fields to the model. For more information, please see Indexing custom models.

(Optional) Implement get_showsimilar_url

The result list items create links to the edit view for Page models by default. It's also possiable to implement get_showsimilar_url to customize link URL for Page, Image, Document or custom models.

from django.urls import reverse

class BreadType(index.Indexed, models.Model):
    ...

    def get_showimilar_url(self):
        return reverse("breads_breadtype_modeladmin_edit", args=(self.id,))

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

wagtail-showsimilar-0.1.0.tar.gz (10.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

wagtail_showsimilar-0.1.0-py3-none-any.whl (11.8 kB view details)

Uploaded Python 3

File details

Details for the file wagtail-showsimilar-0.1.0.tar.gz.

File metadata

  • Download URL: wagtail-showsimilar-0.1.0.tar.gz
  • Upload date:
  • Size: 10.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.9

File hashes

Hashes for wagtail-showsimilar-0.1.0.tar.gz
Algorithm Hash digest
SHA256 25700a45508f738db4583cdac4248e00378f42093dce1ae52ad1feb42a9a3b92
MD5 c032bd44b67b669913302909333ce41f
BLAKE2b-256 02364deae6ed2ab34acad48afafe23f8d03c03f11979af62dab825376126a344

See more details on using hashes here.

File details

Details for the file wagtail_showsimilar-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for wagtail_showsimilar-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 57136c1df5fda100c102d4d7db0adbfb0bdd4a2d1be27e09a9c019418613b68c
MD5 6d8eadbd3aa98d23f86e4882c21613a0
BLAKE2b-256 5089c13f907acf258f10e7dde3883de9c8540b3e4369ef23fc434f803c3c9db9

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 files

0.0.1

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page