Skip to content

Commit

Permalink
Merge pull request #380 from vstoykov/update-django
Browse files Browse the repository at this point in the history
Fixes #379 Support for Django 1.10
  • Loading branch information
vstoykov authored Jul 14, 2016
2 parents e9425df + 5cde74e commit 5061679
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 16 deletions.
6 changes: 5 additions & 1 deletion imagekit/forms/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ def clean(self, data, initial=None):

if data and data != initial:
spec = self.get_spec(source=data)
data = generate(spec)
f = generate(spec)
# Name is required in Django 1.4. When we drop support for it
# then we can dirrectly return the result from `generate(spec)`
f.name = data.name
return f

return data
17 changes: 7 additions & 10 deletions imagekit/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,16 +132,13 @@ def generate(generator):
"""
content = generator.generate()

# If the file doesn't have a name, Django will raise an Exception while
# trying to save it, so we create a named temporary file.
if not getattr(content, 'name', None):
f = NamedTemporaryFile()
f.write(content.read())
f.seek(0)
content = f

return File(content)
f = File(content)
# The size of the File must be known or Django will try to open a file
# without a name and raise an Exception.
f.size = len(content.read())
# After getting the size reset the file pointer for future reads.
content.seek(0)
return f


def call_strategy_method(file, method_name):
Expand Down
21 changes: 19 additions & 2 deletions tests/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,23 @@
if os.getenv('TERM'):
NOSE_ARGS.append('--with-progressive')

DEBUG = True
TEMPLATE_DEBUG = DEBUG
CACHE_BACKEND = 'locmem://'

# Django >= 1.8
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.contrib.auth.context_processors.auth',
'django.template.context_processors.debug',
'django.template.context_processors.i18n',
'django.template.context_processors.media',
'django.template.context_processors.static',
'django.template.context_processors.tz',
'django.contrib.messages.context_processors.messages',
],
},
},
]
30 changes: 27 additions & 3 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
[tox]
envlist =
py35-django19, py35-django18,
py34-django19, py34-django18, py34-django17, py34-django16,
py35-django110, py35-django19, py35-django18,
py34-django110, py34-django19, py34-django18, py34-django17, py34-django16,
py33-django18, py33-django17, py33-django16, py33-django15,
py27-django19, py27-django18, py27-django17, py27-django16, py27-django15, py27-django14,
py27-django110, py27-django19, py27-django18, py27-django17, py27-django16, py27-django15, py27-django14,

[testenv]
commands = python setup.py test

[testenv:py35-django110]
basepython = python3.5
deps =
Django>=1.10b1,<1.11
django-nose==1.4.4

[testenv:py35-django19]
basepython = python3.5
deps =
Expand All @@ -20,6 +26,12 @@ deps =
Django>=1.8,<1.9
django-nose==1.4.2

[testenv:py34-django110]
basepython = python3.4
deps =
Django>=1.10b1,<1.11
django-nose==1.4.4

[testenv:py34-django19]
basepython = python3.4
deps =
Expand All @@ -42,6 +54,7 @@ deps =
basepython = python3.4
deps =
Django>=1.6,<1.7
django-nose<=1.4.2

[testenv:py33-django18]
basepython = python3.3
Expand All @@ -59,11 +72,19 @@ deps =
basepython = python3.3
deps =
Django>=1.6,<1.7
django-nose<=1.4.2

[testenv:py33-django15]
basepython = python3.3
deps =
Django>=1.5,<1.6
django-nose==1.4

[testenv:py27-django110]
basepython = python2.7
deps =
Django>=1.10b1,<1.11
django-nose==1.4.4

[testenv:py27-django19]
basepython = python2.7
Expand All @@ -87,13 +108,16 @@ deps =
basepython = python2.7
deps =
Django>=1.6,<1.7
django-nose<=1.4.2

[testenv:py27-django15]
basepython = python2.7
deps =
Django>=1.5,<1.6
django-nose==1.4

[testenv:py27-django14]
basepython = python2.7
deps =
Django>=1.4,<1.5
django-nose==1.4

0 comments on commit 5061679

Please sign in to comment.