Skip to content

Support Django 5.2.1 and elasticsearch-dsl 7.x #101

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion django_elastic_migrations/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from django_elastic_migrations.utils import loading
from django_elastic_migrations.utils.django_elastic_migrations_log import get_logger

__version__ = '0.9.0'
__version__ = '7.0.0a1'

default_app_config = 'django_elastic_migrations.apps.DjangoElasticMigrationsConfig' # pylint: disable=invalid-name

Expand Down
8 changes: 5 additions & 3 deletions django_elastic_migrations/indexes.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from django.db import ProgrammingError
from elasticsearch import TransportError
from elasticsearch.helpers import expand_action, bulk
from elasticsearch_dsl import Index as ESIndex, DocType as ESDocType, Q as ESQ, Search
from elasticsearch_dsl import Index as ESIndex, Document as ESDocType, Q as ESQ, Search

from django_elastic_migrations import es_client, environment_prefix, es_test_prefix, dem_index_paths, get_logger, codebase_id
from django_elastic_migrations.exceptions import DEMIndexNotFound, DEMDocTypeRequiresGetReindexIterator, \
Expand Down Expand Up @@ -885,15 +885,17 @@ def doc_type(self, doc_type=None) -> DEMDocType:
if active_version_name and self.__doc_type._doc_type:
self.__doc_type._doc_type.index = active_version_name

return super(DEMIndex, self).doc_type(doc_type)
# Return the doc_type directly since newer elasticsearch-dsl versions don't have doc_type method
return self.__doc_type
else:
if self.get_version_id() and not self.__doc_type:
version_model = self.get_version_model()
self.__base_dem_index = DEMIndexManager.get_dem_index(self.get_base_name())
doc_type = self.__base_dem_index.doc_type()
doc_type_index_backup = doc_type._doc_type.index
doc_type._doc_type.index = version_model.name
self.__doc_type = super(DEMIndex, self).doc_type(doc_type)
# Use doc_type directly since newer elasticsearch-dsl versions don't have doc_type method
self.__doc_type = doc_type
if not self.hash_matches(version_model.json_md5):
doc_type._doc_type.index = doc_type_index_backup
our_hash, our_json = self.get_index_hash_and_json()
Expand Down
21 changes: 17 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,24 +49,37 @@ def get_version(*file_paths):
license='MIT',
include_package_data=True,
install_requires=[
# TBD: GH issue #3 includes support for elasticsearch-dsl>=6.2.0
"Django>=1.8", "elasticsearch-dsl>=6.0.0,<6.2.0", "texttable>=1.2.1",
# Updated to support Django 5.2.1 and elasticsearch-dsl 7.x
"Django>=1.8", "elasticsearch-dsl>=7.0.0,<8.0.0", "texttable>=1.2.1",
"multiprocessing-logging>=0.2.6"
],
zip_safe=False,
keywords='Django Elasticsearch',
python_requires=">=3.6, <=4.0",
python_requires=">=3.8, <4.0",
classifiers=[
'Development Status :: 4 - Beta',
'Framework :: Django',
'Framework :: Django :: 1.11',
'Framework :: Django :: 2.0',
'Framework :: Django :: 2.1',
'Framework :: Django :: 2.2',
'Framework :: Django :: 3.0',
'Framework :: Django :: 3.1',
'Framework :: Django :: 3.2',
'Framework :: Django :: 4.0',
'Framework :: Django :: 4.1',
'Framework :: Django :: 4.2',
'Framework :: Django :: 5.0',
'Framework :: Django :: 5.1',
'Framework :: Django :: 5.2',
'Intended Audience :: Developers',
'License :: OSI Approved :: MIT License',
'Natural Language :: English',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: 3.11',
'Programming Language :: Python :: 3.12',
],
)
Loading