Package release

ocyan-compat-django-oscar-elasticsearch

mandel/stable ยท Version 3.0.2

MandelBlog compatibility distribution for Django Oscar Elasticsearch

Metadata

author_email MandelBlog <[email protected]>
classifiers
  • Framework :: Django
  • Framework :: Django :: 5.2
  • License :: OSI Approved :: BSD License
  • Programming Language :: Python :: 3
  • Programming Language :: Python :: 3.10
  • Programming Language :: Python :: 3.11
  • Programming Language :: Python :: 3.12
description_content_type text/markdown
dynamic
  • license-file
license Copyright (c) 2011-present Tangent Communications PLC and individual contributors. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. Neither the name of Tangent Communications PLC nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
license_file
  • LICENSE
  • NOTICE
project_urls
  • Homepage, https://git.mandelblog.com/mandel-plugins/django-oscar-elasticsearch
requires_dist
  • Django<6,>=4.2
  • django-oscar<5,>=3.2.5
  • purl<2,>=1.6
  • elasticsearch<9,>=8
  • django-oscar-odin<0.3,>=0.2.2
  • coverage<8,>=7; extra == "test"
  • mock<6,>=5; extra == "test"
  • sorl-thumbnail<13,>=12.10; extra == "test"
  • pytest<9,>=8; extra == "test"
  • pytest-django<5,>=4.8; extra == "test"
  • ruff<1,>=0.8; extra == "dev"
  • pylint<4,>=3; extra == "dev"
  • pylint-django<3,>=2.6; extra == "dev"
requires_python >=3.10

Release files

FileTest resultsHistory
ocyan_compat_django_oscar_elasticsearch-3.0.2-py3-none-any.whl
Size
65 KB
Type
Python Wheel
Python
3
  • Uploaded to mandel/stable by Mandel-publish 2026-08-09 19:57:47
ocyan_compat_django_oscar_elasticsearch-3.0.2.tar.gz
Size
45 KB
Type
Source
  • Uploaded to mandel/stable by Mandel-publish 2026-08-09 19:57:51

Django Oscar Elasticsearch

MandelBlog compatibility distribution

ocyan.compat.django-oscar-elasticsearch is a private MandelBlog compatibility distribution based on upstream django-oscar-elasticsearch 3.0.0. It preserves the public Python import namespace (oscar_elasticsearch), Django app identity, and search behaviour. Its packaging changes remove the upstream mandatory uwsgidecorators-fallback dependency, which is not imported by the upstream runtime package and cannot resolve on supported Python 3.12, and constrain django-oscar-odin to its compatible 0.2.x API line. Upstream source imports symbols that were renamed in django-oscar-odin 0.3.

Do not install this distribution alongside upstream django-oscar-elasticsearch: both own oscar_elasticsearch. MandelBlog packages must depend on this compatibility distribution explicitly.

Supported MandelBlog runtime

The certified target is Python 3.10โ€“3.12, Django 4.2โ€“5.2, Django Oscar 3.2.5โ€“4.x, Elasticsearch Python client 8.x, and django-oscar-odin 0.2.x. The compatibility distribution must not be installed alongside upstream django-oscar-elasticsearch, because both provide the same import namespace.

Before enabling indexing, configure OSCAR_ELASTICSEARCH_SERVER_URLS with explicit http/https service URLs. TLS verification is enabled by default; use OSCAR_ELASTICSEARCH_CA_CERTS for a private CA and, where required, OSCAR_ELASTICSEARCH_API_KEY or the paired username/password settings. The package never contacts Elasticsearch during import or Django system checks.

The update_oscar_index management command is intentionally confirmation gated: run it with --confirm only after reviewing the target configuration. Signals may enqueue updates after application startup, but no indexing occurs during package import, app construction, or manage.py check.

Validation uses built wheel and sdist artifacts in clean Python 3.12 environments. Editable installs are not part of the supported workflow.

See NOTICE for upstream attribution, modification details, and the update policy. The included BSD-3-Clause licence text is the authoritative licence for the upstream 3.0.0 source archive.

PyPI - Version

๐Ÿš€ Major Overhaul Update!

The latest version (3.0.0) includes a complete overhaul with significant updates to the codebase, new features, and performance enhancements.

๐Ÿ“– About

Django Oscar Elasticsearch is a search app that integrates Elasticsearch with the Django Oscar framework for improved search functionality.

๐Ÿ†• What's New

๐Ÿ“ฆ Installation

Follow these steps to set up the project:

  1. Install the package:
    pip install django-oscar-elasticsearch
    
  2. Update your INSTALLED_APPS in Django settings:
    INSTALLED_APPS = [
        ...
        "oscar_elasticsearch.search.apps.OscarElasticSearchConfig",
        "widget_tweaks",
    ]
    
  3. Configure the necessary settings as outlined in the project documentation.

๐Ÿ›  Configuration

๐Ÿ“œ Usage

Django Oscar Elasticsearch is designed primarily to index products and categories from Django Oscar, but it can also index any Django model or external data types, such as CSV or Excel files.

Indexing Django Models

You can configure custom search handlers to index any Django model. Define a search document, map the fields you want to index, and create a corresponding search handler.

Create the index definition

from django.contrib.auth import get_user_model

from oscar.core.loading import get_class, get_model

get_oscar_index_settings = get_class(
    "search.indexing.settings", "get_oscar_index_settings"
)

OSCAR_INDEX_SETTINGS = get_oscar_index_settings()

BaseElasticSearchApi = get_class("search.api.search", "BaseElasticSearchApi")
ESModelIndexer = get_class("search.indexing.indexer", "ESModelIndexer")


class UserElasticsearchIndex(BaseElasticSearchApi, ESModelIndexer):
    INDEX_NAME = "users"
    INDEX_MAPPING = {
        "properties": {
            "id": {"type": "integer", "store": True},
            "full_name": {"type": "text"},
            "is_active": {"type": "boolean"}
        }
    }
    INDEX_SETTINGS = OSCAR_INDEX_SETTINGS
    Model = get_user_model()

    def make_documents(self, objects):
        for user in objects:
            yield {"_id": user.id, "_source": {"id": user.id, "full_name": user.get_full_name(), "is_active": user.is_active}}

Indexing users into elasticsearch, this can be done in a management command for example

from django.contrib.auth import get_user_model
from oscar_elasticsearch.search import settings

from myprojects.usersearch import UserElasticsearchIndex

User = get_user_model()


with UserElasticsearchIndex().reindex() as index:
    for chunk in chunked(users, settings.INDEXING_CHUNK_SIZE):
        index.reindex_objects(chunk)

Searching for users on full_name

from myprojects.usersearch import UserElasticsearchIndex

# non paginated, returns a queryset of selected model
users = UserElasticsearchIndex().search(
    from_=0,
    to=10,
    query_string="henk",
    search_fields=["full_name^1.5"],
    filters={"term": {"is_active_": True}}, # only active users
)

# paginated, returns a paginator object that extends from the django paginator
paginator = UserElasticsearchIndex().paginated_search(
    from_=0,
    to=10,
    query_string="henk",
    search_fields=["full_name^1.5"],
    filters={"term": {"is_active_": True}}, # only active users
)

๐Ÿค Contributing

Contributions are welcome! Please submit issues and pull requests to the repository.

๐Ÿ“„ License

Oscar is released under the permissive New BSD license (see summary).

๐Ÿ“ซ Contact

For questions or support, please contact the maintainers via GitHub issues.