Fixes #379 Support for Django 1.10

This commit is contained in:
Venelin Stoykov 2016-07-11 01:34:50 +03:00
parent e9425df833
commit 5cde74e3e2
4 changed files with 58 additions and 16 deletions

View file

@ -24,6 +24,10 @@ class ProcessedImageField(ImageField, SpecHost):
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

View file

@ -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):

View file

@ -47,6 +47,23 @@ NOSE_ARGS = [
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
tox.ini
View file

@ -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 =
@ -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 =
@ -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
@ -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
@ -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