melinath / django-daguerre

On-the-fly image manipulation for Django.
http://django-daguerre.readthedocs.org/
BSD 3-Clause "New" or "Revised" License
85 stars 15 forks source link

Django 1.9 compatibility #83

Closed mislavcimpersak closed 8 years ago

mislavcimpersak commented 8 years ago

I've made several changes to make django-daguerre compatibile with Django 1.9.

First I've added testing Django 1.9 against Python 2.7, 3.4 and 3.5. Since official Django support for Python 3.3 has ended with Django 1.8 I have taken out of travis and tox configs testing Django 1.9 against Python 3.3.

Django 1.9 release notes - Python compatibility

Django 1.9 requires Python 2.7, 3.4, or 3.5. We highly recommend and only officially support the latest release of each series.

The Django 1.8 series is the last to support Python 3.2 and 3.3.

Second, Django 1.9 dropped it's custom SortedDict data type. I've replaced SortedDict with Python's OrderedDict. Since original author was sorting the SortedDict I've sorted the OrderedDict accordingly. Below is the example comparing results of current sorting of SortedDict and new sorting of OrderedDict.

# py27 dj18
import itertools
from django.utils.datastructures import SortedDict

kwargs = {'z-word': 1, 'm-word': 4, 'b-word': 2, 'e-word': 22}
kwargs = SortedDict(kwargs)
kwargs.keyOrder.sort()
print(list(itertools.chain(kwargs.keys(), kwargs.values())))
>>> ['b-word', 'e-word', 'm-word', 'z-word', 2, 22, 4, 1]

# py35 dj18
import itertools
from collections import OrderedDict

kwargs = {'z-word': 1, 'm-word': 4, 'b-word': 2, 'e-word': 22}
kwargs = OrderedDict(sorted(kwargs.items(), key=lambda item: item[0], reverse=False))
print(list(itertools.chain(kwargs.keys(), kwargs.values())))
>>> ['b-word', 'e-word', 'm-word', 'z-word', 2, 22, 4, 1]

And last get_model method is imported from a different path depending on the Django version.

mislavcimpersak commented 8 years ago

I'm closing this myself :D Some more stuff is needed.

Will reopen later on.

melinath commented 8 years ago

Cool, thanks for putting in the work on this! We'd love to add 1.9 support.

mislavcimpersak commented 8 years ago

Ok. I'll update my code or my team mate will do a new pull request with updates for Django 1.9. My team mate and me didn't quite talked it through who's doing what today.

But don't worry, daguerre will have Django 1.9 support soon :)