Skip to content

Commit

Permalink
Merge pull request #200 from browniebroke/update-django-support
Browse files Browse the repository at this point in the history
Update supported versions of Django
  • Loading branch information
respondcreate authored Feb 8, 2023
2 parents 318e033 + a960b90 commit 2163d49
Show file tree
Hide file tree
Showing 13 changed files with 53 additions and 121 deletions.
32 changes: 5 additions & 27 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,30 +13,8 @@ jobs:
matrix:
os: [ubuntu-20.04]
python-version: [python3.9, python3.8]
django-version: [django3.2, django3.1, django3.0, django2.2, django2.1, django2.0]
drf-version: [drf3.12, drf3.11, drf3.10, drf3.09]
exclude:
- os: ubuntu-20.04
django-version: django3.2
drf-version: drf3.10
- os: ubuntu-20.04
django-version: django3.1
drf-version: drf3.10
- os: ubuntu-20.04
django-version: django3.2
drf-version: drf3.09
- os: ubuntu-20.04
django-version: django3.1
drf-version: drf3.09
- os: ubuntu-20.04
django-version: django3.0
drf-version: drf3.09
- os: ubuntu-20.04
django-version: django2.1
drf-version: drf3.12
- os: ubuntu-20.04
django-version: django2.0
drf-version: drf3.12
django-version: [django4.0, django3.2, django3.1, django3.0]
drf-version: [drf3.14, drf3.13, drf3.12, drf3.11]
name: ${{ matrix.os }}-${{ matrix.python-version }}-${{ matrix.django-version }}-${{ matrix.drf-version }}
steps:
- name: "Set job environments"
Expand Down Expand Up @@ -66,7 +44,7 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install --upgrade tox tox-gh-actions testfixtures
python -m pip install --upgrade 'tox>=3,<4' tox-gh-actions testfixtures
- name: Tox tests
run: |
tox -e $TOXENV
Expand All @@ -89,10 +67,10 @@ jobs:
needs: run-tests
steps:
- uses: actions/checkout@master
- name: Set up Python 3.7
- name: Set up Python 3.9
uses: actions/setup-python@v1
with:
python-version: 3.7
python-version: 3.9
- name: Install pypa/build
run: >-
python -m
Expand Down
15 changes: 7 additions & 8 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -32,29 +32,28 @@ Compatibility

- `Django <https://www.djangoproject.com/>`_:

- 2.0.x
- 2.1.x
- 2.2.x
- 3.0.x
- 3.1.x
- 3.2.x

**NOTE**: Python 3.6 does not have support for Django <= 1.x.
- 4.0.x
- 4.1.x

**NOTE**: The 1.4 release dropped support for Django 1.5.x & 1.6.x.

**NOTE**: The 1.7 release dropped support for Django 1.7.x.

**NOTE**: The 2.1 release dropped support for Django 1.9.x.

- `Pillow <https://pillow.readthedocs.io/en/latest/index.html>`_ >= 2.4.0
**NOTE**: The 3.0 release dropped support for Django 2.x.

- `Pillow <https://pillow.readthedocs.io/en/latest/index.html>`_ >= 6.2.0

- `Django REST Framework <http://www.django-rest-framework.org/>`_:

- 3.9.x
- 3.10.x
- 3.11.x
- 3.12.x
- 3.13.x
- 3.14.x

Documentation
=============
Expand Down
16 changes: 11 additions & 5 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -39,20 +39,20 @@ Compatibility

- `Django <https://www.djangoproject.com/>`_:

- 2.0.x
- 2.1.x
- 2.2.x
- 3.0.x
- 3.1.x
- 3.2.x
- 4.0.x
- 4.1.x

- `Pillow <https://pillow.readthedocs.io/en/latest/index.html>`_ >=2.4.0

- `Django REST Framework <http://www.django-rest-framework.org/>`_:

- 3.9.x
- 3.10.x
- 3.11.x
- 3.12.x
- 3.13.x
- 3.14.x

Code
====
Expand All @@ -78,6 +78,12 @@ Table of Contents

Release Notes
=============
3.0
^^^
- Removed support for Django < 3.x. Thanks, `@browniebroke <https://github.com/browniebroke>`_!
- Added support for Django 4.0 & 4.1. Thanks, `@browniebroke <https://github.com/browniebroke>`_!
- General code clean-up, improved Django REST Framework support and doc updates. Thanks, `@browniebroke <https://github.com/browniebroke>`_!

2.2
^^^
- Added WEBP support for sizers & filters. Thanks, `@ahmedaljazzar <https://github.com/ahmedaljazzar>`_!
Expand Down
4 changes: 2 additions & 2 deletions docs/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ Python Compatibility
Django Compatibility
--------------------

- 2.0.x
- 2.2.x
- 3.0.x
- 3.1.x
- 3.2.x
- 4.0.x
- 4.1.x

Dependencies
------------
Expand Down
2 changes: 1 addition & 1 deletion docs/overview.rst
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ Flexible in development, light-weight in production
Fully Tested & Python 3 Ready
-----------------------------

``django-versatileimagefield`` is a rock solid, `fully-tested <https://coveralls.io/r/WGBH/django-versatileimagefield>`_ Django app that is compatible with Python 3.6 thru 3.9 and works with Django 2.0.x thru 3.2.x
``django-versatileimagefield`` is a rock solid, `fully-tested <https://coveralls.io/r/WGBH/django-versatileimagefield>`_ Django app that is compatible with Python 3.6 thru 3.9 and works with Django 3.0.x thru 4.1.x

Get Started
-----------
Expand Down
3 changes: 1 addition & 2 deletions post_processor_runtests.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@
from django.test.utils import get_runner
# Run post-processor tests
os.environ['DJANGO_SETTINGS_MODULE'] = 'tests.post_processor.test_settings'
if django.VERSION >= (1, 7):
django.setup()
django.setup()
TestRunnerPostProcessor = get_runner(
settings,
'tests.post_processor.discover_tests.DiscoverPostProcessorRunner'
Expand Down
15 changes: 8 additions & 7 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
name='django-versatileimagefield',
packages=find_packages(),
version='2.2',
author=u'Jonathan Ellenberger',
author='Jonathan Ellenberger',
author_email='[email protected]',
url='http://github.com/respondcreate/django-versatileimagefield/',
license='MIT License, see LICENSE',
Expand All @@ -15,7 +15,11 @@
"creating new images from the one assigned to the field.",
long_description=open('README.rst').read(),
zip_safe=False,
install_requires=['Pillow>=2.4.0', 'python-magic>=0.4.15,<1.0.0'],
install_requires=[
'Pillow>=2.4.0',
'python-magic>=0.4.15,<1.0.0',
'Django>=3.0',
],
include_package_data=True,
keywords=[
'django',
Expand All @@ -24,20 +28,17 @@
'Development Status :: 5 - Production/Stable',
'Environment :: Web Environment',
'Framework :: Django',
'Framework :: Django :: 2.0',
'Framework :: Django :: 2.1',
'Framework :: Django :: 2.2',
'Framework :: Django :: 3.0',
'Framework :: Django :: 3.1',
'Framework :: Django :: 3.2',
'Framework :: Django :: 4.0',
'Framework :: Django :: 4.1',
'Intended Audience :: Developers',
'License :: OSI Approved :: MIT License',
'Natural Language :: English',
'Operating System :: OS Independent',
'Programming Language :: Python',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
Expand Down
2 changes: 2 additions & 0 deletions tests/settings_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,3 +75,5 @@
},
},
]

DEFAULT_AUTO_FIELD = 'django.db.models.AutoField'
24 changes: 1 addition & 23 deletions tests/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ def test_widget_javascript(self):
response = self.client.get(self.admin_url)
self.assertEqual(response.status_code, 200)
# Test that javascript loads correctly
if DJANGO_VERSION[0] >= 3 and DJANGO_VERSION[1] >= 1:
if DJANGO_VERSION >= (3, 1):
expected_response = '<script src="/static/versatileimagefield/js/versatileimagefield.js"></script>'
else:
expected_response = '<script type="text/javascript" src="/static/versatileimagefield/js/versatileimagefield.js"></script>'
Expand Down Expand Up @@ -1081,28 +1081,6 @@ def test_corrupt_file(self):

instance.image.delete(save=False)

@skipIf(django.VERSION >= (2, 2), "Not applicable for Django>=2.2")
def test_webp_wrong_dimensions(self):
"""Test WebP image dimensions behavior on Django<2.2"""
with self.assertRaisesMessage(RuntimeError, "could not create decoder object"):
VersatileImageTestModel.objects.create(
img_type='webp-no-dimensions',
image="python-logo.webp",
width=0,
height=0
)

try:
VersatileImageTestModel.objects.create(
img_type='webp-with-dimensions',
image="python-logo.webp",
width=580,
height=164
)
except RuntimeError as e:
self.fail("ImageField raised RuntimeError unexpectedly! msg: %s" % e)

@skipIf(django.VERSION < (2, 2), "Different behavior exists on Django<2.2")
def test_webp_dimensions_dimensions(self):
"""Test no failures on all WebP image dimensions"""
try:
Expand Down
8 changes: 4 additions & 4 deletions tests/urls.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
from django.conf import settings
from django.conf.urls import include, url
from django.urls import include, path, re_path
from django.contrib import admin

admin.autodiscover()

urlpatterns = [
url(r'^admin/', admin.site.urls),
path('admin/', admin.site.urls),
]

if settings.DEBUG:
urlpatterns = [
url(
re_path(
r'^media/(?P<path>.*)$',
'django.views.static.serve',
{'document_root': settings.MEDIA_ROOT, 'show_indexes': True}
),
url(r'', include('django.contrib.staticfiles.urls')),
path('', include('django.contrib.staticfiles.urls')),
] + urlpatterns
28 changes: 9 additions & 19 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -3,48 +3,38 @@ minversion = 3.23.0
requires:
pip >= 21.0.1
envlist =
py{3.6,3.7}-django{20,21,22}-drf{307,308,309,310,311}
py{3.8,3.9}-django{22}-drf{309,310,311,312}
py{3.8,3.9}-django{30,31,32}-drf{311,312}
py{3.8,3.9}-django{30,31,32,40,41}-drf{311,312,313,314}

[gh-actions]
python =
3.6: py3.6
3.7: py3.7
3.8: py3.8
3.9: py3.9

[travis:env]
DJANGO =
2.0: django20
2.2: django22
3.0: django30
3.1: django31
3.2: django32
4.0: django40
4.1: django41

[testenv]
passenv = TRAVIS TRAVIS_* GITHUB_*
deps=
coverage
coveralls
testfixtures
django20: Django>=2.0.13,<2.1.0
django21: Django>=2.1.14,<2.2.0
django22: Django>=2.2.19,<3.0.0
pytz
django30: Django>=3.0.13,<3.1.0
django31: Django>=3.1.7,<3.2.0
django32: Django>=3.2.0rc1,<3.3.0
drf304: djangorestframework>=3.4.7,<3.5.0
drf305: djangorestframework>=3.5.4,<3.6.0
drf306: djangorestframework>=3.6.4,<3.7.0
drf307: djangorestframework>=3.7.7,<3.8.0
drf308: djangorestframework>=3.8.2,<3.9.0
drf309: djangorestframework>=3.9.4,<3.10.0
drf310: djangorestframework>=3.10.3,<3.11.0
django32: Django>=3.2.0,<3.3.0
django40: Django>=4.0.0,<4.1.0
django41: Django>=4.1.0,<4.2.0
drf311: djangorestframework>=3.11.2,<3.12.0
drf312: djangorestframework>=3.12.4,<3.13.0
drf313: djangorestframework>=3.13,<3.14
drf314: djangorestframework>=3.14,<3.15
flake8
coveralls
sitepackages = False
recreate = False
commands =
Expand Down
2 changes: 1 addition & 1 deletion versatileimagefield/files.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class VersatileImageFieldFile(VersatileImageMixIn, ImageFieldFile):

def __setstate__(self, state):
self.__dict__.update(state)
if DJANGO_VERSION[0] >= 3 and DJANGO_VERSION[1] > 0:
if DJANGO_VERSION >= (3, 1):
self.storage = self.field.storage
self._create_on_demand = state.get('_create_on_demand')
self._ppoi_value = state.get('_ppoi_value')
Expand Down
23 changes: 1 addition & 22 deletions versatileimagefield/widgets.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import django
from django.forms.widgets import ClearableFileInput, HiddenInput, MultiWidget, Select
from django.template.loader import render_to_string
from django.utils.safestring import mark_safe

CENTERPOINT_CHOICES = (
Expand All @@ -18,7 +16,6 @@

class ClearableFileInputWithImagePreview(ClearableFileInput):

has_template_widget_rendering = django.VERSION >= (1, 11)
template_name = 'versatileimagefield/forms/widgets/versatile_image.html'

def get_hidden_field_id(self, name):
Expand All @@ -36,20 +33,6 @@ def get_ppoi_id(self, name):
def get_point_stage_id(self, name):
return name + '_point-stage'

def render(self, name, value, attrs=None, renderer=None):
"""
Render the widget as an HTML string.
Overridden here to support Django < 1.11.
"""
if self.has_template_widget_rendering:
return super(ClearableFileInputWithImagePreview, self).render(
name, value, attrs=attrs, renderer=renderer
)
else: # pragma: no cover
context = self.get_context(name, value, attrs)
return render_to_string(self.template_name, context)

def get_sized_url(self, value):
"""Do not fail completely on invalid images"""
try:
Expand All @@ -63,11 +46,7 @@ def get_sized_url(self, value):

def get_context(self, name, value, attrs):
"""Get the context to render this widget with."""
# Initialize widget context.
context = {}

if self.has_template_widget_rendering:
context = super(ClearableFileInputWithImagePreview, self).get_context(name, value, attrs)
context = super(ClearableFileInputWithImagePreview, self).get_context(name, value, attrs)

# It seems Django 1.11's ClearableFileInput doesn't add everything to the 'widget' key, so we can't use it
# in MultiWidget. Add it manually here.
Expand Down

0 comments on commit 2163d49

Please sign in to comment.