Fix all deprecation warnings #385

Merged
merged 8 commits into from Mar 30, 2016

Projects

None yet

2 participants

@timheap
Contributor
timheap commented Mar 24, 2016

I've fixed all deprecation warnings from all versions of Django supported by taggit, while maintaining backwards compatibility with all currently supported versions, and with all tests passing.

This involved adding some helpers for the recently renamed field.rel.to/field.remote_field.model, and changing the use of add_lazy_relation to lazy_related_operation on Django 1.9.

SQL names are quoted using the correct function now, fixing #380 and #383.

on_delete=models.CASCADE has been added to all ForeignKeys where it was missing, including in tests and migrations. This is backwards compatible with current code and projects, as on_delete=models.CASCADE was the assumed default previously.

Warnings due to different versions of unittest bundled through different version of Django have been sorted out, as has a warning from Django for Python 3.3, 3.4.

Finally, DeprecationWarnings are now show in test output. As there are no more deprecation warnings, the test output is still useable as it is before, without being polluted with lots of DeprecationWarning noise.

@timheap timheap referenced this pull request in wagtail/wagtail Mar 24, 2016
Closed

Fix DeprecationWarnings from Django 1.9 #2392

@frewsxcv frewsxcv and 1 other commented on an outdated diff Mar 24, 2016
tests/tests.py
@@ -56,7 +57,22 @@ def _get_form_str(self, form_str):
return form_str
def assert_form_renders(self, form, html):
- self.assertHTMLEqual(str(form), self._get_form_str(html))
+ # Django causes a DeprecationWarning on Python 3.3, 3.4
+ if (3, 3) >= sys.version_info > (3, 5):
@frewsxcv
frewsxcv Mar 24, 2016 Collaborator

Won't this always evaluate to False?

@timheap
timheap Mar 24, 2016 Contributor

Good catch. Which means if the DeprecationWarnings are not appearing, that particular issue must have gone away... I'll look in to it.

@timheap
Contributor
timheap commented Mar 24, 2016

I fixed the backwards conditional that you spotted, properly silencing the DeprecationWarning from Django in those versions of Python.

@frewsxcv
Collaborator

Sorry for the delay! Thanks a bunch, your contributions are greatly appreciated

@frewsxcv frewsxcv merged commit 58c675d into alex:develop Mar 30, 2016

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment