Skip to content

Commit

Permalink
Django 4.0 Support (#107)
Browse files Browse the repository at this point in the history
* Remove deprecated Django imports and make compatible with Django 4.0

* Drop EOL Django 3.1

* Fix tox-gh-actions configuration

* Don't require Django to be installed in order to run setup.py

* Add explicit install_requires to aid in pip dependency resolution
  • Loading branch information
johnthagen authored Dec 10, 2021
1 parent 421e318 commit a01ceeb
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 25 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install tox tox-gh-actions
python -m pip install tox tox-gh-actions
- name: Test with tox
run: tox
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ class SiteConfiguration(SingletonModel):
Installation
------------

This application requires Django 2.2, 3.1, or 3.2.
This application requires Django 2.2, 3.2, or 4.0.

* Install the package using `pip install django-solo`
* Add ``solo`` or ``solo.apps.SoloAppConfig`` to your ``INSTALLED_APPS`` setting.
Expand Down
23 changes: 18 additions & 5 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from setuptools import setup, find_packages
import os
import solo
import re

from setuptools import setup, find_packages

README = os.path.join(os.path.dirname(__file__), 'README.md')

Expand All @@ -12,11 +12,24 @@
except Exception:
long_description = ''


def get_version(package):
"""
Return package version as listed in `__version__` in `__init__.py`.
"""
with open(os.path.join(package, '__init__.py')) as file:
init_py = file.read()
return re.search("__version__ = ['\"]([^'\"]+)['\"]", init_py).group(1)


version = get_version('solo')

setup(
name='django-solo',
version=solo.__version__,
description=solo.__doc__,
version=version,
description='Django Solo helps working with singletons',
python_requires='>=3.6',
install_requires=['django>=2.2'],
packages=find_packages(),
url='https://github.com/lazybird/django-solo/',
author='lazybird',
Expand All @@ -27,8 +40,8 @@
license='Creative Commons Attribution 3.0 Unported',
classifiers=[
'Framework :: Django :: 2.2',
'Framework :: Django :: 3.1',
'Framework :: Django :: 3.2',
'Framework :: Django :: 4.0',
'Intended Audience :: Developers',
'Operating System :: OS Independent',
'Programming Language :: Python',
Expand Down
1 change: 0 additions & 1 deletion solo/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@


__version__ = '1.2.0'
__doc__ = 'Django Solo helps working with singletons'

if django.VERSION < (3, 2):
default_app_config = 'solo.apps.SoloAppConfig'
10 changes: 3 additions & 7 deletions solo/admin.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
from django.urls import re_path
from django.contrib import admin
from django.http import HttpResponseRedirect
from django.utils.encoding import force_str
from django.utils.translation import gettext as _

from solo.models import DEFAULT_SINGLETON_INSTANCE_ID
from solo import settings as solo_settings

try:
from django.utils.encoding import force_unicode
except ImportError:
from django.utils.encoding import force_text as force_unicode
from django.utils.translation import ugettext as _


class SingletonModelAdmin(admin.ModelAdmin):
object_history_template = "admin/solo/object_history.html"
Expand Down Expand Up @@ -56,7 +52,7 @@ def get_urls(self):

def response_change(self, request, obj):
msg = _('%(obj)s was changed successfully.') % {
'obj': force_unicode(obj)}
'obj': force_str(obj)}
if '_continue' in request.POST:
self.message_user(request, msg + ' ' +
_('You may edit it again below.'))
Expand Down
2 changes: 1 addition & 1 deletion solo/templatetags/solo_tags.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from django import template
from django.utils.translation import ugettext as _
from django.utils.translation import gettext as _

from solo import settings as solo_settings

Expand Down
19 changes: 10 additions & 9 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
# Configure which test environments are run for each Github Actions Python version.
[gh-actions]
python =
3.6: py36
3.7: py37
3.8: py38
3.9: py39
3.10: py310
3.6: py36-django{22,32}
3.7: py37-django{22,32}
3.8: py38-django{22,32,40}
3.9: py39-django{22,32,40}
3.10: py310-django{22,32,40}

[tox]
envlist =
py{36,37,38,39,310}-django{22,31,32}
py{36,37}-django{22,32}
py{38,39,310}-django{22,32,40}

[testenv]
deps =
django22: Django>=2.2,<2.3
django31: Django>=3.1,<3.2
django32: Django>=3.2,<3.3
django22: Django>=2.2,<3.0
django32: Django>=3.2,<4.0
django40: Django>=4.0,<4.1
commands =
{envpython} {toxinidir}/manage.py test solo --settings=solo.tests.settings

0 comments on commit a01ceeb

Please sign in to comment.