Skip to main content

wagtail input panel

Project description

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,))

Project details


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.0.1.tar.gz (10.0 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.0.1-py3-none-any.whl (11.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: wagtail-showsimilar-0.0.1.tar.gz
  • Upload date:
  • Size: 10.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.63.0 importlib-metadata/4.10.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.10

File hashes

Hashes for wagtail-showsimilar-0.0.1.tar.gz
Algorithm Hash digest
SHA256 0b605bb138b795796ed4368050fa1bd9af325ef419ebada16e3f99464d8b1e31
MD5 4d557aee87160233b333957e31903f4b
BLAKE2b-256 6841446c8cdef63098fc935c647b54e61c70b7b6034a5b19695a483e65fa5654

See more details on using hashes here.

File details

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

File metadata

  • Download URL: wagtail_showsimilar-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 11.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.63.0 importlib-metadata/4.10.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.10

File hashes

Hashes for wagtail_showsimilar-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 94e53115bc7aad54cd61572eb7ae0b11c1263e19d3e10043ee93b54f4b44b884
MD5 9a678784493e4976bb728996f9af5db6
BLAKE2b-256 688300425ba4dcf87bbc5f0cb761c8c99381b9f316bae132375dea117ce43d83

See more details on using hashes here.

Supported by

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