nshafer / django-hashid-field

Django Model Field that uses Hashids to obscure the value
MIT License
370 stars 40 forks source link

Add django 3, remove python 2.7 #37

Closed hhamana closed 4 years ago

hhamana commented 4 years ago

35, #36,

Drop Python 2.7 support, and change to more idiomatic Python 3. Removes all references to six compatibility dependency, which also has the effect of adding support for Django 3.0. Also tested with Python 3.8, no issues noticed, so I added it to the test matrix. Supported Python versions are now from 3.6 to 3.8. Note I didn't add DRF 3.10, it shouldn't have issues either, but I didn't check.

Django 3 adds some deprecations warnings related to Django 4, django.utils.translation.ugettext_lazy() is deprecated in favor of django.utils.translation.gettext_lazy() and force_text() is deprecated in favor of force_str() I updated as such.

Locally tested with Python 3.8, Django 2.2, 2.2.8, and 3.0

There was one outstanding error detected, only with Django 3. test_subquery_lookup fails, with TypeError: 'Query' object is not iterable. It refers to the loop in lookups.py, l129 for rhs_value in self.rhs:. The previous check couldn't pickup the bound method _prepare, as it has been removed in Django 3. It originally only returned self anyway.

nshafer commented 4 years ago

Most of the code in lookups.py is compatibility stuff for django version older than 1.11. So I'm going to be removing most of it along with removing 2.7 support. Thanks for getting this started, though!