Skip to content
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

Resolve various Django 1.8 deprecations #1165

Closed
wants to merge 5 commits into from
Closed

Resolve various Django 1.8 deprecations #1165

wants to merge 5 commits into from

Conversation

benspaulding
Copy link
Contributor

This pull request handles the deprecation in Django 1.8 of:

  • django.utils.datastructures.SortedDict
  • django.utils.importlib
  • django.utils.unittest

For each case it prefers code from the Python stdlib, and if that import fails uses the old Django code. You can see individual commit messages for more information on each change.

This should resolve issue #1162 as well as pull request #1137.

The app_loading module had to shuffle things a bit. When it was
importing the function it raised a [RuntimeError][]. Simply importing
the module resolved that.

[RuntimeError]: https://gist.github.com/benspaulding/f36eaf483573f8e5f777
The two are not exactly they same, but they are equivalent for
Haystack's needs.
There is no need to fallback to importing unittest2 because Django 1.5
is the oldest Django we support, so django.utils.unittest is guaranteed
to exist.
@acdha
Copy link
Contributor

acdha commented Apr 6, 2015

At first glance, this looks very nice – thanks!

@acdha acdha self-assigned this Apr 6, 2015
@acdha acdha added this to the v2.4.0 milestone Apr 6, 2015
@benspaulding
Copy link
Contributor Author

@acdha Thanks for looking at this so quickly. Evidently I need to fix something from commit e37c1f3 about unittest. I’ll look when I get a chance and push a fix.

@acdha
Copy link
Contributor

acdha commented Apr 7, 2015

Oddly this caused no issue on Django <= 1.7, but it causes numerous
errors on Django 1.8.
@SalahAdDin
Copy link

👍
Sooo good.

@troygrosfield
Copy link
Contributor

👍

@troygrosfield
Copy link
Contributor

#1175 should also be merged along with this one since this isn't actually running the test suite against django 1.8 (covered that in #1175).

@andreif
Copy link
Contributor

andreif commented Apr 27, 2015

@troygrosfield it may be better to merge #1175 into #1165

@troygrosfield
Copy link
Contributor

@benspaulding, care to pull in the changes from #1175 to get this to test against django 1.8? Then after that's done I'll close #1175.

@SalahAdDin
Copy link

Merge please :D

@acdha
Copy link
Contributor

acdha commented May 12, 2015

I've reshuffled things a bit into https://github.com/acdha/django-haystack/tree/django-1.8

Currently that's down to 4 test failures, all related to the mock models:

======================================================================
ERROR: test_prepare (test_haystack.test_fields.CharFieldTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/cadams/Projects/django-haystack/test_haystack/test_fields.py", line 32, in test_prepare
    mock.tag = mock_tag
  File "/Users/cadams/.virtualenvs/django-haystack/lib/python2.7/site-packages/django/db/models/fields/related.py", line 668, in __set__
    (value, self.field.rel.to._meta.object_name)
ValueError: Cannot assign "<MockTag: MockTag object>": "MockTag" instance isn't saved in the database.

======================================================================
ERROR: test_prepare (test_haystack.test_fields.EdgeNgramFieldTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/cadams/Projects/django-haystack/test_haystack/test_fields.py", line 146, in test_prepare
    mock.tag = mock_tag
  File "/Users/cadams/.virtualenvs/django-haystack/lib/python2.7/site-packages/django/db/models/fields/related.py", line 668, in __set__
    (value, self.field.rel.to._meta.object_name)
ValueError: Cannot assign "<MockTag: MockTag object>": "MockTag" instance isn't saved in the database.

======================================================================
ERROR: test_prepare (test_haystack.test_fields.IntegerFieldTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/cadams/Projects/django-haystack/test_haystack/test_fields.py", line 201, in test_prepare
    mock.tag = mock_tag
  File "/Users/cadams/.virtualenvs/django-haystack/lib/python2.7/site-packages/django/db/models/fields/related.py", line 668, in __set__
    (value, self.field.rel.to._meta.object_name)
ValueError: Cannot assign "<MockTag: MockTag object>": "MockTag" instance isn't saved in the database.

======================================================================
ERROR: test_prepare (test_haystack.test_fields.NgramFieldTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/cadams/Projects/django-haystack/test_haystack/test_fields.py", line 89, in test_prepare
    mock.tag = mock_tag
  File "/Users/cadams/.virtualenvs/django-haystack/lib/python2.7/site-packages/django/db/models/fields/related.py", line 668, in __set__
    (value, self.field.rel.to._meta.object_name)
ValueError: Cannot assign "<MockTag: MockTag object>": "MockTag" instance isn't saved in the database.

@benspaulding
Copy link
Contributor Author

Sorry I missed the activity here. @acdha Do you need anything further from me regarding this?

@acdha
Copy link
Contributor

acdha commented May 13, 2015

@benspaulding Not immediately, although if you have time to work on the mock models I wouldn't complain. I'm hoping to dig into that again on Friday.

@benspaulding
Copy link
Contributor Author

Okay, I don’t have time in the next few days, but I’ll check back here later and tackle that if it has not already been handled.

@acdha
Copy link
Contributor

acdha commented Jun 3, 2015

The Django 1.8 branch has merged as of bd8e512

@acdha acdha closed this Jun 3, 2015
@acdha
Copy link
Contributor

acdha commented Jun 5, 2015

There's a release candidate on PyPI now:

pip install django-haystack==2.4.0rc1

@Koed00
Copy link
Contributor

Koed00 commented Jun 6, 2015

Testing 2.4.0rc1 and still getting these deprecation warnings:

/local/lib/python2.7/site-packages/haystack/utils/app_loading.py:7: RemovedInDjango19Warning: The utilities in django.db.models.loading are deprecated in favor of the new application loading system.
  from django.db.models.loading import get_app, get_model, get_models

/local/lib/python2.7/site-packages/haystack/utils/app_loading.py:32: RemovedInDjango19Warning: get_app_config(app_label).models_module supersedes get_app(app_label).
  app_mod = get_app(label)

Last one only comes up with the management commands.
I'm feeling adventurous and will have a stab at it.

@Koed00
Copy link
Contributor

Koed00 commented Jun 6, 2015

Created a pull request #1206 with fixes for this

@acdha
Copy link
Contributor

acdha commented Jun 6, 2015

Thanks – my goal for 2.4 is to have it clean against Django 1.8. If we can
get the 1.9 deprecations in before then it's fine but otherwise I figure we
can get that in by 2.5. I'd really like to avoid going so long between
releases in the future.

On Sat, Jun 6, 2015 at 11:01 AM, Ilan Steemers notifications@github.com
wrote:

Created a pull request #1206
#1206 with fixes
for this


Reply to this email directly or view it on GitHub
#1165 (comment)
.

@Koed00
Copy link
Contributor

Koed00 commented Jun 6, 2015

I tested #1206 in my own project that was giving the warnings earlier and it's now nice and clean.
Now that I delved a bit deeper into the code, I can see how deprecating Django 1.6 would be a good goal for a future release.

@acdha
Copy link
Contributor

acdha commented Jun 6, 2015 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants