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
Django 2.0 compatibility #1582
Django 2.0 compatibility #1582
Conversation
This reverts commit 7a9ac38.
@@ -1458,7 +1458,7 @@ def test_boost(self): | |||
]) | |||
|
|||
|
|||
@unittest.skipIf(pysolr.__version__ < (3, 1, 1), 'content extraction requires pysolr > 3.1.0') | |||
@unittest.skipIf(tuple(pysolr.__version__.split('.')) < (3, 1, 1), 'content extraction requires pysolr > 3.1.0') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could also use pysolr.version_info
but that will trigger a deprecation warning on setuptools >= 8.0 since that's no longer a simple tuple.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That actually seems to have an additional problem as the parsed version still contains strings instead of integers.
Either we could do a pysolr.version_info < parse_version('3.1.1')
with the corresponding import or we just drop that annotation? Seems relatively unlikely that anyone is running the test suite with a version of pysolr from 2013, no?
What do you prefer?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dropping it does make sense - if anyone is running tests on an install that old it seems unlikely that they'd have upgraded haystack but frozen pysolr
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, I dropped the annotation.
By the way, thank you @acdha for replying so fast and maintaining django-haystack! Anything else that needs updating in this MR? |
I wanted to review it in more detail first but at first glance it looked good |
@acdha did you already have time to take a look at this MR? any way I can support you in getting this merged? |
I can vouch for this, we have been using @mpauly fork for 2 days in our dev branch and it works like a charm. |
@mpauly the main thing is testing – since I’m not using that combination at the moment I haven’t done more than look at the code. I’d like to e.g. confirm test coverage isn’t omitting anything important. |
@acdha I just added a test to see if ModelSearchIndex properly excludes related fields by default - seems this was not tested before. I also updated the corresponding line in Is there any reason why |
@acdha I just merged master into this branch (I probably should have rebased - sorry about that) |
It seems that before I was not running the solr tests correctly, so I had to do more updates to fix some failing tests. Over the weekend I did the following changes:
There might potentially be bugs in some functionality related to the geo lookups, however tests are passing with Django 1.11 and 2.0. We are also running this fork in production with Django 2.0 and have not experienced any problems yet. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could add:
'Framework :: Django :: 1.11',
'Framework :: Django :: 2.0',
to setup.py
.
.travis.yml
Outdated
- DJANGO_VERSION=">=1.8,<1.9" VERSION_ES=">=2.0.0,<3.0.0" | ||
- DJANGO_VERSION=">=1.9,<1.10" VERSION_ES=">=2.0.0,<3.0.0" | ||
- DJANGO_VERSION=">=1.10,<1.11" VERSION_ES=">=2.0.0,<3.0.0" | ||
- DJANGO_VERSION=">=1.11,<1.12" VERSION_ES=">=1.0.0,<2.0.0" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
<1.12 -> <2.0
.travis.yml
Outdated
|
||
matrix: | ||
allow_failures: | ||
- python: 'pypy' | ||
- python: 2.7 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These builds should be excluded rather than "allowed_failures".
@@ -33,5 +34,11 @@ def add_arguments(self, parser): | |||
) | |||
|
|||
def handle(self, **options): | |||
call_command('clear_index', **options) | |||
call_command('update_index', **options) | |||
clear_options = copy.copy(options) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
options.copy()
?
@@ -2,11 +2,12 @@ | |||
|
|||
from __future__ import absolute_import, division, print_function, unicode_literals | |||
|
|||
import django |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unused
setup.py
Outdated
@@ -12,7 +12,7 @@ | |||
from setuptools import setup | |||
|
|||
install_requires = [ | |||
'Django>=1.8,<1.12', | |||
'Django>=1.11,<2.1', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wouldn't specify an upper bound -- it might be that this will work fine with Django 2.1 without any changes.
tox.ini
Outdated
deps = | ||
Django>=1.8,<1.9 | ||
Django>=1.11,<1.12 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
<2.0
""" | ||
Confirm that command-line option parsing produces the same results as using call_command() directly, | ||
mostly as a sanity check for the logic in rebuild_index which combines the option_lists for its | ||
component commands. | ||
""" | ||
from haystack.management.commands.rebuild_index import Command | ||
|
||
update_mock.return_value = '' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can put return_value=''
in the @patch
calls.
test_haystack/test_indexes.py
Outdated
@@ -623,6 +629,7 @@ def test_excludes(self): | |||
self.assertTrue(isinstance(self.emsi.fields['pub_date'], indexes.DateTimeField)) | |||
self.assertTrue('text' in self.emsi.fields) | |||
self.assertTrue(isinstance(self.emsi.fields['text'], indexes.CharField)) | |||
self.assertFalse('related_models' in self.m2mmsi.fields) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
assertNotIn
@@ -69,6 +69,9 @@ def test_rebuild_index_using(self, m1, m2): | |||
@patch('haystack.management.commands.update_index.Command.handle') | |||
@patch('haystack.management.commands.clear_index.Command.handle') | |||
def test_rebuild_index(self, mock_handle_clear, mock_handle_update): | |||
mock_handle_clear.return_value = '' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can put return_value=''
in the @patch
calls.
args, kwargs = clear_mock.call_args | ||
|
||
self.assertIn('interactive', kwargs) | ||
self.assertEqual(False, kwargs['interactive']) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for boolean comparisons: self.assertIs(kwargs['interactive'], False)
@timgraham Thanks for the comments, all of them should be implemented now. |
I can confirm that @mpauly's fork works fine with Django 2.0. Tested rebuild_index command, searching, faceting and autocomplete in combination with ElasticSearch. No problems here. |
In my case, django-haystack 2.7.0 works fine with Django 2 without any changes. Would be great to have this explucitly supported though. |
waiting for d2 support :D |
Any idea when this branch will be officially committed to the master package? |
It's waiting for more people to test it. If you have time to volunteer in
that regard it'll happen faster.
|
@acdha WRT more people testing, what are we looking for? 5, 10? I don't have a production system. But I'm happy to test with my rinky dink setup, and vouch if it works for me. How many vouchsafes are we short? I don't think people, myself, included like fuzzy "more people" statements. |
I was thinking more different combinations: i.e. I don't use ElasticSearch
with Haystack much so at the very least I think it'd make sense to make
sure someone has tested it with at least Solr, ES, and Whoosh.
|
Ahh...very good clarification. Thanks. I wont be able to help much on that front :) |
tested with django 2 & elasticsearch on aws, everything worked fine |
Apparently it will work with Whoosh on AWS as well. |
We are running Xapian-haystack, that works well with this branch |
Thanks to @mpauly and @timgraham for working on this and @dani0805, @andrewbenedictwallace, @RabidCicada, @webtweakers, @nadimtuhin, and @JonLevischi for testing.
Thanks to @mpauly and @timgraham for working on this and @dani0805, @andrewbenedictwallace, @RabidCicada, @webtweakers, @nadimtuhin, and @JonLevischi for testing.
This is now in https://pypi.python.org/pypi/django-haystack/2.8.0 |
Hi,
this PR adds Django 2.0 compatibility.
As the PR #1557 did not see any progress recently I implemented everything needed for Django 2.0 compatibility here.
In particular I rewrote the rebuild_index command to strip certain arguments that are not used in the clear_index and update_index commands respectively. This is implemented in a relatively adhoc way, however looking at the amount of changes made to rebuild_index in the past I figured this might be the easiest way to implement this change.
Additionally I added Django 2.0 to the tests and excluded the combination Django2.0 + Python2.7 from the test suite so that the tests still pass. Maybe one should also consider adding python 3.6 to the test suite, however I did not do that yet.
Also note the change I made to
test_haystack/solr_tests/test_solr_backend.py
. This was necessary due to the recent update in pysolr. That update broke the django-haystack tests, aspysolr.__version__
is now a string instead of a tuple. The fix I implemented should be backwards compatible.Please let me know if there is anything this MR needs to get merged, cheers,
Martin