From b2aad8da313471235376c83af5d9388c96c6d70a Mon Sep 17 00:00:00 2001
From: Tomas
Date: Tue, 24 Sep 2019 10:44:30 +0200
Subject: [PATCH 01/10] Adding back compatibility
---
.travis.yml | 65 ++++++++++
README.rst | 18 +--
example/app/test_msf.py | 29 ++++-
example/app/views.py | 7 +-
example/example/urls.py | 57 ++++++---
example/run_tests.py | 7 +-
multiselectfield/db/fields.py | 5 +-
setup.py | 6 +-
tox.ini | 219 +++++++++++++++++++++++++++++++++-
9 files changed, 373 insertions(+), 40 deletions(-)
diff --git a/.travis.yml b/.travis.yml
index 873d9f2..41e573e 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,27 +1,92 @@
language: python
python:
+ - "2.6"
- "2.7"
+ - "3.3"
- "3.4"
- "3.5"
- "3.6"
env:
+ - DJANGO_VERSION='Django>=1.4,<1.5'
+ - DJANGO_VERSION='Django>=1.5,<1.6'
+ - DJANGO_VERSION='Django>=1.6,<1.7'
+ - DJANGO_VERSION='Django>=1.7,<1.8'
+ - DJANGO_VERSION='Django>=1.8,<1.9'
+ - DJANGO_VERSION='Django>=1.9,<1.10'
+ - DJANGO_VERSION='Django>=1.10,<1.11'
- DJANGO_VERSION='Django>=1.11,<2.0'
- DJANGO_VERSION='Django>=2.0,<2.1'
- DJANGO_VERSION='Django>=2.1,<2.2'
- DJANGO_VERSION='https://github.com/django/django/archive/master.tar.gz'
matrix:
exclude:
+ - python: "2.6"
+ env: DJANGO_VERSION='Django>=1.7,<1.8'
+ - python: "2.6"
+ env: DJANGO_VERSION='Django>=1.8,<1.9'
+ - python: "2.6"
+ env: DJANGO_VERSION='Django>=1.9,<1.10'
+ - python: "2.6"
+ env: DJANGO_VERSION='Django>=1.10,<1.11'
+ - python: "2.6"
+ env: DJANGO_VERSION='Django>=1.11,<2.0'
+ - python: "2.6"
+ env: DJANGO_VERSION='https://github.com/django/django/archive/master.tar.gz'
- python: "2.7"
+ env: DJANGO_VERSION='https://github.com/django/django/archive/master.tar.gz'
+ - python: "3.3"
+ env: DJANGO_VERSION='Django>=1.4,<1.5'
+ - python: "3.3"
+ env: DJANGO_VERSION='Django>=1.5,<1.6'
+ - python: "3.3"
+ env: DJANGO_VERSION='Django>=1.9,<1.10'
+ - python: "3.3"
+ env: DJANGO_VERSION='Django>=1.10,<1.11'
+ - python: "3.3"
+ env: DJANGO_VERSION='Django>=1.11,<2.0'
+ - python: "3.3"
env: DJANGO_VERSION='Django>=2.0,<2.1'
- python: "2.7"
env: DJANGO_VERSION='Django>=2.1,<2.2'
- python: "2.7"
env: DJANGO_VERSION='https://github.com/django/django/archive/master.tar.gz'
+ - python: "3.4"
+ env: DJANGO_VERSION='Django>=1.4,<1.5'
+ - python: "3.4"
+ env: DJANGO_VERSION='Django>=1.5,<1.6'
+ - python: "3.4"
+ env: DJANGO_VERSION='Django>=1.6,<1.7'
- python: "3.4"
env: DJANGO_VERSION='Django>=2.1,<2.2'
- python: "2.7"
env: DJANGO_VERSION='https://github.com/django/django/archive/master.tar.gz'
+ - python: "3.5"
+ env: DJANGO_VERSION='Django>=1.4,<1.5'
+ - python: "3.5"
+ env: DJANGO_VERSION='Django>=1.5,<1.6'
+ - python: "3.5"
+ env: DJANGO_VERSION='Django>=1.6,<1.7'
+ - python: "3.5"
+ env: DJANGO_VERSION='Django>=1.7,<1.8'
+ - python: "3.5"
+ env: DJANGO_VERSION='Django>=2.1,<=2.2'
+ - python: "3.6"
+ env: DJANGO_VERSION='Django>=1.4,<1.5'
+ - python: "3.6"
+ env: DJANGO_VERSION='Django>=1.5,<1.6'
+ - python: "3.6"
+ env: DJANGO_VERSION='Django>=1.6,<1.7'
+ - python: "3.6"
+ env: DJANGO_VERSION='Django>=1.7,<1.8'
+ - python: "3.6"
+ env: DJANGO_VERSION='Django>=1.8,<1.9'
+ - python: "3.6"
+ env: DJANGO_VERSION='Django>=1.9,<1.10'
+ - python: "3.6"
+ env: DJANGO_VERSION='Django>=1.10,<1.11'
+ - python: "3.6"
+ env: DJANGO_VERSION='Django>=2.1,<=2.2'
allow_failures:
- env: DJANGO_VERSION='https://github.com/django/django/archive/master.tar.gz'
diff --git a/README.rst b/README.rst
index 628dbad..fb5d7ac 100644
--- a/README.rst
+++ b/README.rst
@@ -14,9 +14,9 @@ A new model field and form field. With this you can get a multiple select from a
This egg is inspired by this `snippet `_.
-Supported Python versions: 2.7, 3.4+
+Supported Python versions: 2.6, 2.7, 3.3+
-Supported Django versions: 1.11-2.0+
+Supported Django versions: 1.4-2.0+
Installation
============
@@ -35,25 +35,25 @@ Configure your models.py
.. code-block:: python
from multiselectfield import MultiSelectField
-
+
# ...
-
+
MY_CHOICES = (('item_key1', 'Item title 1.1'),
('item_key2', 'Item title 1.2'),
('item_key3', 'Item title 1.3'),
('item_key4', 'Item title 1.4'),
('item_key5', 'Item title 1.5'))
-
+
MY_CHOICES2 = ((1, 'Item title 2.1'),
(2, 'Item title 2.2'),
(3, 'Item title 2.3'),
(4, 'Item title 2.4'),
(5, 'Item title 2.5'))
-
+
class MyModel(models.Model):
-
+
# .....
-
+
my_field = MultiSelectField(choices=MY_CHOICES)
my_field2 = MultiSelectField(choices=MY_CHOICES2,
max_choices=3,
@@ -103,7 +103,7 @@ Django REST Framework comes with a ``MultipleChoiceField`` that works perfectly
.. code-block:: python
from rest_framework import fields, serializers
-
+
from myapp.models import MY_CHOICES, MY_CHOICES2
class MyModelSerializer(serializers.HyperlinkedModelSerializer):
diff --git a/example/app/test_msf.py b/example/app/test_msf.py
index dc057ee..ccec10e 100644
--- a/example/app/test_msf.py
+++ b/example/app/test_msf.py
@@ -32,8 +32,12 @@
u = str
-def get_field(model, name):
- return model._meta.get_field(name)
+if VERSION < (1, 9):
+ def get_field(model, name):
+ return model._meta.get_field_by_name(name)[0]
+else:
+ def get_field(model, name):
+ return model._meta.get_field(name)
class MultiSelectTestCase(TestCase):
@@ -73,8 +77,12 @@ def test_values_list(self):
# call Field.from_db_field, it simply returns a Python representation
# of the data in the database (which in our case is a string of
# comma-separated values). The bug was fixed in Django 1.8+.
- self.assertListEqual(tag_list_list, [['sex', 'work', 'happy']])
- self.assertListEqual(categories_list_list, [['1', '3', '5']])
+ if VERSION >= (1, 6) and VERSION < (1, 8):
+ self.assertStringEqual(tag_list_list, [u('sex,work,happy')])
+ self.assertStringEqual(categories_list_list, [u('1,3,5')])
+ else:
+ self.assertListEqual(tag_list_list, [['sex', 'work', 'happy']])
+ self.assertListEqual(categories_list_list, [['1', '3', '5']])
def test_form(self):
form_class = modelform_factory(Book, fields=('title', 'tags', 'categories'))
@@ -131,17 +139,28 @@ def test_named_groups_form(self):
self.assertEqual(len(form_class.base_fields), 1)
form = form_class(initial={'published_in': ['BC', 'AK']})
- expected_html = u("""
""")
actual_html = form.as_p()
+ if (1, 11) <= VERSION < (2, 0):
+ # Django 1.11+ does not assign 'for' attributes on labels if they
+ # are group labels
+ expected_html = expected_html.replace('label for="id_published_in_0"', 'label')
+
+ if VERSION < (1, 6):
+ # Django 1.6 renders the Python repr() for each group (eg: tuples
+ # with HTML entities), so we skip the test for that version
+ self.assertEqual(expected_html.replace('\n', ''), actual_html.replace('\n', ''))
if VERSION >= (2, 0):
expected_html = expected_html.replace('input checked="checked"', 'input checked')
+ if VERSION >= (1, 7):
+ self.assertHTMLEqual(expected_html, actual_html)
self.assertHTMLEqual(expected_html, actual_html)
diff --git a/example/app/views.py b/example/app/views.py
index 6142ef1..5feb26f 100644
--- a/example/app/views.py
+++ b/example/app/views.py
@@ -14,12 +14,15 @@
# You should have received a copy of the GNU Lesser General Public License
# along with this software. If not, see .
-
+from django import VERSION
from django.conf import settings
from django.contrib.auth import login
from django.contrib.auth import get_user_model
-from django.urls import reverse
+if VERSION >= (2, 0):
+ from django.urls import reverse
+else:
+ from django.core.urlresolvers import reverse
from django.http import HttpResponseRedirect
diff --git a/example/example/urls.py b/example/example/urls.py
index 0e60278..baee4c1 100644
--- a/example/example/urls.py
+++ b/example/example/urls.py
@@ -14,11 +14,26 @@
# You should have received a copy of the GNU Lesser General Public License
# along with this software. If not, see .
+from django import VERSION
from django.conf import settings
try:
from django.conf.urls import include, url
-except ImportError:
- from django.urls import include, url
+ # Compatibility for Django > 1.8
+ def patterns(prefix, *args):
+ if VERSION < (1, 9):
+ from django.conf.urls import patterns as django_patterns
+ return django_patterns(prefix, *args)
+ elif prefix != '':
+ raise NotImplementedError("You need to update your URLConf for "
+ "Django 1.10, or tweak it to remove the "
+ "prefix parameter")
+ else:
+ return list(args)
+except ImportError: # Django < 1.4
+ if VERSION < (1, 4):
+ from django.conf.urls.defaults import include, patterns, url
+ else:
+ from django.urls import include, url
from django.contrib import admin
from django.views.static import serve
@@ -29,18 +44,26 @@
'packages': ('django.conf',),
}
-urlpatterns = [
- url(r'^', include('app.urls')),
- url(r'^admin/', admin.site.urls),
-]
-
-urlpatterns += [
- url(
- r'^%s(?P.*)$' % settings.MEDIA_URL[1:],
- serve,
- {
- 'document_root': settings.MEDIA_ROOT,
- 'show_indexes': True,
- },
- ),
-]
+if VERSION < (1, 11):
+ urlpatterns = patterns(
+ '',
+ url(r'^', include('app.urls')),
+ url(r'^admin/', include(admin.site.urls)),
+ )
+ urlpatterns += patterns(
+ '',
+ url(r'^%s(?P.*)$' % settings.MEDIA_URL[1:]),
+ )
+else:
+ urlpatterns = [
+ url(r'^', include('app.urls')),
+ url(r'^admin/', admin.site.urls),
+ url(
+ r'^%s(?P.*)$' % settings.MEDIA_URL[1:],
+ serve,
+ {
+ 'document_root': settings.MEDIA_ROOT,
+ 'show_indexes': True,
+ },
+ ),
+ ]
diff --git a/example/run_tests.py b/example/run_tests.py
index ec3f39a..42bf316 100644
--- a/example/run_tests.py
+++ b/example/run_tests.py
@@ -19,6 +19,7 @@
import os
import sys
+import django
from django.conf import ENVIRONMENT_VARIABLE
from django.core import management
from django.core.wsgi import get_wsgi_application
@@ -29,6 +30,10 @@
else:
os.environ[ENVIRONMENT_VARIABLE] = sys.argv[1]
-application = get_wsgi_application()
+if django.VERSION[0] == 1 and django.VERSION[1] >= 7:
+ from django.core.wsgi import get_wsgi_application as get_wsgi_application_v1
+ application = get_wsgi_application_v1()
+else:
+ application = get_wsgi_application()
management.call_command('test', 'app')
diff --git a/multiselectfield/db/fields.py b/multiselectfield/db/fields.py
index 0fd8966..85bc5eb 100644
--- a/multiselectfield/db/fields.py
+++ b/multiselectfield/db/fields.py
@@ -102,7 +102,10 @@ def get_choices_selected(self, arr_choices):
return choices_selected
def value_to_string(self, obj):
- value = super(MultiSelectField, self).value_from_object(obj)
+ try:
+ value = self._get_val_from_obj(obj)
+ except AttributeError:
+ value = super(MultiSelectField, self).value_from_object(obj)
return self.get_prep_value(value)
def validate(self, value, model_instance):
diff --git a/setup.py b/setup.py
index acf9632..c5bba96 100644
--- a/setup.py
+++ b/setup.py
@@ -41,8 +41,10 @@ def read(*rnames):
'Framework :: Django',
'License :: OSI Approved :: GNU Library or Lesser General Public License (LGPL)',
'Programming Language :: Python :: 2',
+ 'Programming Language :: Python :: 2.6',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
+ 'Programming Language :: Python :: 3.3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
@@ -54,13 +56,13 @@ def read(*rnames):
packages=find_packages(),
include_package_data=True,
tests_require=[
- 'django>=1.11',
+ 'django>=1.4',
'tox',
'coverage',
'flake8',
],
install_requires=[
- 'django>=1.11',
+ 'django>=1.4',
],
zip_safe=False,
)
diff --git a/tox.ini b/tox.ini
index df70693..fecc625 100644
--- a/tox.ini
+++ b/tox.ini
@@ -1,5 +1,5 @@
[tox]
-envlist = py{27,34,35,36}-dj111,py{34,35,36,37}-dj20,py{35,36,37}-dj21
+envlist = py{26,27,33,34,35,36}-dj{14,15,16,16,17,18,19,110,111},py{34,35,36,37}-dj{14,15,16,16,17,18,19,110,111,20},py{35,36,37}-dj{21,22},
[testenv]
usedevelop = True
@@ -12,6 +12,141 @@ commands =
install_command =
pip install {opts} {packages}
+[testenv:py26-dj14]
+basepython = python2.6
+deps =
+ django==1.4.22
+ pillow==1.7.8
+ PyYAML==3.10
+ coveralls==0.3
+ flake8
+
+[testenv:py26-dj15]
+basepython = python2.6
+deps =
+ django==1.5.12
+ pillow==1.7.8
+ PyYAML==3.10
+ coveralls==0.3
+ flake8
+
+[testenv:py26-dj16]
+basepython = python2.6
+deps =
+ django==1.6.11
+ pillow==1.7.8
+ PyYAML==3.10
+ coveralls==0.3
+ flake8
+
+[testenv:py26-dj17]
+basepython = python2.6
+deps =
+ django==1.7.11
+ pillow==1.7.8
+ PyYAML==3.10
+ coveralls==0.3
+ flake8
+
+[testenv:py26-dj18]
+basepython = python2.6
+deps =
+ django==1.8.17
+ pillow==1.7.8
+ PyYAML==3.10
+ coveralls==0.3
+ flake8
+
+[testenv:py26-dj19]
+basepython = python2.6
+deps =
+ django==1.9.12
+ pillow==1.7.8
+ PyYAML==3.10
+ coveralls==0.3
+ flake8
+
+[testenv:py26-dj110]
+basepython = python2.6
+deps =
+ django==1.10.4
+ pillow==1.7.8
+ PyYAML==3.10
+ coveralls==0.3
+ flake8
+
+[testenv:py26-dj111]
+basepython = python2.6
+deps =
+ django==1.11.15
+ pillow==1.7.8
+ PyYAML==3.13
+ coveralls==0.3
+ flake8
+
+[testenv:py27-dj14]
+basepython = python2.7
+deps =
+ django==1.4.22
+ pillow==1.7.8
+ PyYAML==3.10
+ coveralls==0.3
+ flake8
+
+[testenv:py27-dj15]
+basepython = python2.7
+deps =
+ django==1.5.12
+ pillow==1.7.8
+ PyYAML==3.10
+ coveralls==0.3
+ flake8
+
+[testenv:py27-dj16]
+basepython = python2.7
+deps =
+ django==1.6.11
+ pillow==1.7.8
+ PyYAML==3.10
+ coveralls==0.3
+ flake8
+
+[testenv:py27-dj17]
+basepython = python2.7
+deps =
+ django==1.7.11
+ pillow==1.7.8
+ PyYAML==3.10
+ coveralls==0.3
+ flake8
+
+[testenv:py27-dj18]
+basepython = python2.7
+deps =
+ django==1.8.17
+ pillow==1.7.8
+ PyYAML==3.10
+ coveralls==0.3
+ flake8
+
+[testenv:py27-dj19]
+basepython = python2.7
+deps =
+ django==1.9.12
+ pillow==1.7.8
+ PyYAML==3.10
+ coveralls==0.3
+ flake8
+
+[testenv:py27-dj110]
+basepython = python2.7
+deps =
+ django==1.10.4
+ pillow==1.7.8
+ PyYAML==3.10
+ coveralls==0.3
+ flake8
+
[testenv:py27-dj111]
basepython = python2.7
deps =
@@ -21,6 +156,59 @@ deps =
coveralls==0.3
flake8
+[testenv:py33-dj16]
+basepython = python3.3
+deps =
+ django==1.6.11
+ pillow==1.7.8
+ PyYAML==3.10
+ coveralls==0.3
+ flake8
+
+[testenv:py33-dj17]
+basepython = python3.3
+deps =
+ django==1.7.11
+ pillow==1.7.8
+ PyYAML==3.10
+ coveralls==0.3
+ flake8
+
+[testenv:py33-dj18]
+basepython = python3.3
+deps =
+ django==1.8.17
+ pillow==1.7.8
+ PyYAML==3.10
+ coveralls==0.3
+ flake8
+
+[testenv:py33-dj19]
+basepython = python3.3
+deps =
+ django==1.9.12
+ pillow==1.7.8
+ PyYAML==3.10
+ coveralls==0.3
+ flake8
+
+[testenv:py33-dj110]
+basepython = python3.3
+deps =
+ django==1.10.4
+ pillow==1.7.8
+ PyYAML==3.10
+ coveralls==0.3
+ flake8
+
+[testenv:py33-dj111]
+basepython = python3.3
+deps =
+ django==1.11.15
+ pillow==1.7.8
+ PyYAML==3.13
+ coveralls==0.3
+ flake8
[testenv:py34-dj111]
basepython = python3.4
@@ -40,7 +228,6 @@ deps =
coveralls==0.3
flake8
-
[testenv:py35-dj111]
basepython = python3.5
deps =
@@ -68,6 +255,15 @@ deps =
coveralls==0.3
flake8
+[testenv:py35-dj22]
+basepython = python3.5
+deps =
+ django==2.2.1
+ pillow==2.1.0
+ PyYAML==3.13
+ coveralls==0.3
+ flake8
+
[testenv:py36-dj111]
basepython = python3.6
deps =
@@ -95,6 +291,14 @@ deps =
coveralls==0.3
flake8
+[testenv:py36-dj22]
+basepython = python3.6
+deps =
+ django==2.2.1
+ pillow==2.1.0
+ PyYAML==3.13
+ coveralls==0.3
+ flake8
[testenv:py37-dj20]
basepython = python3.7
@@ -112,4 +316,13 @@ deps =
pillow==2.1.0
PyYAML==3.13
coveralls==0.3
- flake8
\ No newline at end of file
+ flake8
+
+[testenv:py37-dj22]
+basepython = python3.7
+deps =
+ django==2.2.1
+ pillow==2.1.0
+ PyYAML==3.13
+ coveralls==0.3
+ flake8
From 51f3e11e5b6f2ab15b392f154af0413869ee248e Mon Sep 17 00:00:00 2001
From: Tomas
Date: Tue, 24 Sep 2019 11:55:17 +0200
Subject: [PATCH 02/10] Remove python2.6 and 3.3 and fix flake8 errors
---
.travis.yml | 25 --------
example/app/views.py | 3 +-
example/example/urls.py | 7 ++-
tox.ini | 128 +---------------------------------------
4 files changed, 8 insertions(+), 155 deletions(-)
diff --git a/.travis.yml b/.travis.yml
index 41e573e..43eb824 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,9 +1,7 @@
language: python
python:
- - "2.6"
- "2.7"
- - "3.3"
- "3.4"
- "3.5"
- "3.6"
@@ -21,31 +19,8 @@ env:
- DJANGO_VERSION='https://github.com/django/django/archive/master.tar.gz'
matrix:
exclude:
- - python: "2.6"
- env: DJANGO_VERSION='Django>=1.7,<1.8'
- - python: "2.6"
- env: DJANGO_VERSION='Django>=1.8,<1.9'
- - python: "2.6"
- env: DJANGO_VERSION='Django>=1.9,<1.10'
- - python: "2.6"
- env: DJANGO_VERSION='Django>=1.10,<1.11'
- - python: "2.6"
- env: DJANGO_VERSION='Django>=1.11,<2.0'
- - python: "2.6"
- env: DJANGO_VERSION='https://github.com/django/django/archive/master.tar.gz'
- python: "2.7"
env: DJANGO_VERSION='https://github.com/django/django/archive/master.tar.gz'
- - python: "3.3"
- env: DJANGO_VERSION='Django>=1.4,<1.5'
- - python: "3.3"
- env: DJANGO_VERSION='Django>=1.5,<1.6'
- - python: "3.3"
- env: DJANGO_VERSION='Django>=1.9,<1.10'
- - python: "3.3"
- env: DJANGO_VERSION='Django>=1.10,<1.11'
- - python: "3.3"
- env: DJANGO_VERSION='Django>=1.11,<2.0'
- - python: "3.3"
env: DJANGO_VERSION='Django>=2.0,<2.1'
- python: "2.7"
env: DJANGO_VERSION='Django>=2.1,<2.2'
diff --git a/example/app/views.py b/example/app/views.py
index 5feb26f..0078662 100644
--- a/example/app/views.py
+++ b/example/app/views.py
@@ -18,12 +18,13 @@
from django.conf import settings
from django.contrib.auth import login
from django.contrib.auth import get_user_model
+from django.http import HttpResponseRedirect
if VERSION >= (2, 0):
from django.urls import reverse
else:
from django.core.urlresolvers import reverse
-from django.http import HttpResponseRedirect
+
def app_index(request):
diff --git a/example/example/urls.py b/example/example/urls.py
index baee4c1..434007f 100644
--- a/example/example/urls.py
+++ b/example/example/urls.py
@@ -16,8 +16,13 @@
from django import VERSION
from django.conf import settings
+from django.contrib import admin
+from django.views.static import serve
+
+
try:
from django.conf.urls import include, url
+
# Compatibility for Django > 1.8
def patterns(prefix, *args):
if VERSION < (1, 9):
@@ -34,8 +39,6 @@ def patterns(prefix, *args):
from django.conf.urls.defaults import include, patterns, url
else:
from django.urls import include, url
-from django.contrib import admin
-from django.views.static import serve
admin.autodiscover()
diff --git a/tox.ini b/tox.ini
index fecc625..9d221da 100644
--- a/tox.ini
+++ b/tox.ini
@@ -1,5 +1,5 @@
[tox]
-envlist = py{26,27,33,34,35,36}-dj{14,15,16,16,17,18,19,110,111},py{34,35,36,37}-dj{14,15,16,16,17,18,19,110,111,20},py{35,36,37}-dj{21,22},
+envlist = py{27,34,35,36}-dj{14,15,16,16,17,18,19,110,111},py{34,35,36,37}-dj{14,15,16,16,17,18,19,110,111,20},py{35,36,37}-dj{21,22},
[testenv]
usedevelop = True
@@ -12,78 +12,6 @@ commands =
install_command =
pip install {opts} {packages}
-[testenv:py26-dj14]
-basepython = python2.6
-deps =
- django==1.4.22
- pillow==1.7.8
- PyYAML==3.10
- coveralls==0.3
- flake8
-
-[testenv:py26-dj15]
-basepython = python2.6
-deps =
- django==1.5.12
- pillow==1.7.8
- PyYAML==3.10
- coveralls==0.3
- flake8
-
-[testenv:py26-dj16]
-basepython = python2.6
-deps =
- django==1.6.11
- pillow==1.7.8
- PyYAML==3.10
- coveralls==0.3
- flake8
-
-[testenv:py26-dj17]
-basepython = python2.6
-deps =
- django==1.7.11
- pillow==1.7.8
- PyYAML==3.10
- coveralls==0.3
- flake8
-
-[testenv:py26-dj18]
-basepython = python2.6
-deps =
- django==1.8.17
- pillow==1.7.8
- PyYAML==3.10
- coveralls==0.3
- flake8
-
-[testenv:py26-dj19]
-basepython = python2.6
-deps =
- django==1.9.12
- pillow==1.7.8
- PyYAML==3.10
- coveralls==0.3
- flake8
-
-[testenv:py26-dj110]
-basepython = python2.6
-deps =
- django==1.10.4
- pillow==1.7.8
- PyYAML==3.10
- coveralls==0.3
- flake8
-
-[testenv:py26-dj111]
-basepython = python2.6
-deps =
- django==1.11.15
- pillow==1.7.8
- PyYAML==3.13
- coveralls==0.3
- flake8
-
[testenv:py27-dj14]
basepython = python2.7
deps =
@@ -156,60 +84,6 @@ deps =
coveralls==0.3
flake8
-[testenv:py33-dj16]
-basepython = python3.3
-deps =
- django==1.6.11
- pillow==1.7.8
- PyYAML==3.10
- coveralls==0.3
- flake8
-
-[testenv:py33-dj17]
-basepython = python3.3
-deps =
- django==1.7.11
- pillow==1.7.8
- PyYAML==3.10
- coveralls==0.3
- flake8
-
-[testenv:py33-dj18]
-basepython = python3.3
-deps =
- django==1.8.17
- pillow==1.7.8
- PyYAML==3.10
- coveralls==0.3
- flake8
-
-[testenv:py33-dj19]
-basepython = python3.3
-deps =
- django==1.9.12
- pillow==1.7.8
- PyYAML==3.10
- coveralls==0.3
- flake8
-
-[testenv:py33-dj110]
-basepython = python3.3
-deps =
- django==1.10.4
- pillow==1.7.8
- PyYAML==3.10
- coveralls==0.3
- flake8
-
-[testenv:py33-dj111]
-basepython = python3.3
-deps =
- django==1.11.15
- pillow==1.7.8
- PyYAML==3.13
- coveralls==0.3
- flake8
-
[testenv:py34-dj111]
basepython = python3.4
deps =
From 35e1c6f27b410f91e121ea5122dbb47b20d16670 Mon Sep 17 00:00:00 2001
From: Tomas
Date: Tue, 24 Sep 2019 11:58:55 +0200
Subject: [PATCH 03/10] Fix flake8 errors
---
example/app/views.py | 1 -
1 file changed, 1 deletion(-)
diff --git a/example/app/views.py b/example/app/views.py
index 0078662..587443e 100644
--- a/example/app/views.py
+++ b/example/app/views.py
@@ -26,7 +26,6 @@
from django.core.urlresolvers import reverse
-
def app_index(request):
user = get_user_model().objects.get(username='admin')
if not hasattr(user, 'backend'):
From c5d2422e43923201af3559d8384e2ed23f9f4279 Mon Sep 17 00:00:00 2001
From: Tomas
Date: Tue, 24 Sep 2019 12:16:16 +0200
Subject: [PATCH 04/10] Adding travis matrix
---
.travis.yml | 34 +++++++++++++++++++++++++---------
1 file changed, 25 insertions(+), 9 deletions(-)
diff --git a/.travis.yml b/.travis.yml
index 43eb824..5584775 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -5,6 +5,7 @@ python:
- "3.4"
- "3.5"
- "3.6"
+ - "3.7"
env:
- DJANGO_VERSION='Django>=1.4,<1.5'
- DJANGO_VERSION='Django>=1.5,<1.6'
@@ -21,11 +22,8 @@ matrix:
exclude:
- python: "2.7"
env: DJANGO_VERSION='https://github.com/django/django/archive/master.tar.gz'
- env: DJANGO_VERSION='Django>=2.0,<2.1'
- python: "2.7"
env: DJANGO_VERSION='Django>=2.1,<2.2'
- - python: "2.7"
- env: DJANGO_VERSION='https://github.com/django/django/archive/master.tar.gz'
- python: "3.4"
env: DJANGO_VERSION='Django>=1.4,<1.5'
- python: "3.4"
@@ -34,8 +32,6 @@ matrix:
env: DJANGO_VERSION='Django>=1.6,<1.7'
- python: "3.4"
env: DJANGO_VERSION='Django>=2.1,<2.2'
- - python: "2.7"
- env: DJANGO_VERSION='https://github.com/django/django/archive/master.tar.gz'
- python: "3.5"
env: DJANGO_VERSION='Django>=1.4,<1.5'
- python: "3.5"
@@ -45,7 +41,9 @@ matrix:
- python: "3.5"
env: DJANGO_VERSION='Django>=1.7,<1.8'
- python: "3.5"
- env: DJANGO_VERSION='Django>=2.1,<=2.2'
+ env: DJANGO_VERSION='Django>=2.1,<2.2'
+ - python: "3.5"
+ env: DJANGO_VERSION='https://github.com/django/django/archive/master.tar.gz'
- python: "3.6"
env: DJANGO_VERSION='Django>=1.4,<1.5'
- python: "3.6"
@@ -61,9 +59,27 @@ matrix:
- python: "3.6"
env: DJANGO_VERSION='Django>=1.10,<1.11'
- python: "3.6"
- env: DJANGO_VERSION='Django>=2.1,<=2.2'
- allow_failures:
- - env: DJANGO_VERSION='https://github.com/django/django/archive/master.tar.gz'
+ env: DJANGO_VERSION='Django>=2.1,<2.2'
+ - python: "3.6"
+ env: DJANGO_VERSION='https://github.com/django/django/archive/master.tar.gz'
+ - python: "3.7"
+ env: DJANGO_VERSION='Django>=1.4,<1.5'
+ - python: "3.7"
+ env: DJANGO_VERSION='Django>=1.5,<1.6'
+ - python: "3.7"
+ env: DJANGO_VERSION='Django>=1.6,<1.7'
+ - python: "3.7"
+ env: DJANGO_VERSION='Django>=1.7,<1.8'
+ - python: "3.7"
+ env: DJANGO_VERSION='Django>=1.8,<1.9'
+ - python: "3.7"
+ env: DJANGO_VERSION='Django>=1.9,<1.10'
+ - python: "3.7"
+ env: DJANGO_VERSION='Django>=1.10,<1.11'
+ - python: "3.7"
+ env: DJANGO_VERSION='Django>=2.1,<2.2'
+ - python: "3.7"
+ env: DJANGO_VERSION='https://github.com/django/django/archive/master.tar.gz'
install:
- pip install -q $DJANGO_VERSION
From c18868a81e55ede853aa10567aa35ad745b62078 Mon Sep 17 00:00:00 2001
From: Tomas
Date: Tue, 24 Sep 2019 12:28:45 +0200
Subject: [PATCH 05/10] Fix exclude travis matrix
---
.travis.yml | 22 ----------------------
1 file changed, 22 deletions(-)
diff --git a/.travis.yml b/.travis.yml
index 5584775..d88d7de 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -58,28 +58,6 @@ matrix:
env: DJANGO_VERSION='Django>=1.9,<1.10'
- python: "3.6"
env: DJANGO_VERSION='Django>=1.10,<1.11'
- - python: "3.6"
- env: DJANGO_VERSION='Django>=2.1,<2.2'
- - python: "3.6"
- env: DJANGO_VERSION='https://github.com/django/django/archive/master.tar.gz'
- - python: "3.7"
- env: DJANGO_VERSION='Django>=1.4,<1.5'
- - python: "3.7"
- env: DJANGO_VERSION='Django>=1.5,<1.6'
- - python: "3.7"
- env: DJANGO_VERSION='Django>=1.6,<1.7'
- - python: "3.7"
- env: DJANGO_VERSION='Django>=1.7,<1.8'
- - python: "3.7"
- env: DJANGO_VERSION='Django>=1.8,<1.9'
- - python: "3.7"
- env: DJANGO_VERSION='Django>=1.9,<1.10'
- - python: "3.7"
- env: DJANGO_VERSION='Django>=1.10,<1.11'
- - python: "3.7"
- env: DJANGO_VERSION='Django>=2.1,<2.2'
- - python: "3.7"
- env: DJANGO_VERSION='https://github.com/django/django/archive/master.tar.gz'
install:
- pip install -q $DJANGO_VERSION
From 3ab2dd9d38d60ca3d9905ae82fb4f9f173972872 Mon Sep 17 00:00:00 2001
From: Tomas
Date: Tue, 24 Sep 2019 12:33:45 +0200
Subject: [PATCH 06/10] Adding exclude 3.4
---
.travis.yml | 2 ++
1 file changed, 2 insertions(+)
diff --git a/.travis.yml b/.travis.yml
index d88d7de..0b33c0e 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -32,6 +32,8 @@ matrix:
env: DJANGO_VERSION='Django>=1.6,<1.7'
- python: "3.4"
env: DJANGO_VERSION='Django>=2.1,<2.2'
+ - python: "3.4"
+ env: DJANGO_VERSION='https://github.com/django/django/archive/master.tar.gz'
- python: "3.5"
env: DJANGO_VERSION='Django>=1.4,<1.5'
- python: "3.5"
From 27851b8eb58d81d39b5051cc9e7e8165327bb680 Mon Sep 17 00:00:00 2001
From: Tomas
Date: Tue, 24 Sep 2019 13:16:34 +0200
Subject: [PATCH 07/10] Change python3 compatibility
---
.travis.yml | 14 ++++++++++++++
multiselectfield/db/fields.py | 6 ++++--
2 files changed, 18 insertions(+), 2 deletions(-)
diff --git a/.travis.yml b/.travis.yml
index 0b33c0e..a02855a 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -60,6 +60,20 @@ matrix:
env: DJANGO_VERSION='Django>=1.9,<1.10'
- python: "3.6"
env: DJANGO_VERSION='Django>=1.10,<1.11'
+ - python: "3.7"
+ env: DJANGO_VERSION='Django>=1.4,<1.5'
+ - python: "3.7"
+ env: DJANGO_VERSION='Django>=1.5,<1.6'
+ - python: "3.7"
+ env: DJANGO_VERSION='Django>=1.6,<1.7'
+ - python: "3.7"
+ env: DJANGO_VERSION='Django>=1.7,<1.8'
+ - python: "3.7"
+ env: DJANGO_VERSION='Django>=1.8,<1.9'
+ - python: "3.7"
+ env: DJANGO_VERSION='Django>=1.9,<1.10'
+ - python: "3.7"
+ env: DJANGO_VERSION='Django>=1.10,<1.11'
install:
- pip install -q $DJANGO_VERSION
diff --git a/multiselectfield/db/fields.py b/multiselectfield/db/fields.py
index 85bc5eb..cb5e68f 100644
--- a/multiselectfield/db/fields.py
+++ b/multiselectfield/db/fields.py
@@ -20,7 +20,6 @@
from django.db import models
from django.utils.text import capfirst
-from django.utils.encoding import python_2_unicode_compatible
from django.core import exceptions
from ..forms.fields import MultiSelectFormField, MinChoicesValidator, MaxChoicesValidator
@@ -47,7 +46,6 @@ def wrapper(cls):
return wrapper
-@python_2_unicode_compatible
class MSFList(list):
def __init__(self, choices, *args, **kwargs):
@@ -58,6 +56,10 @@ def __str__(msgl):
msg_list = [msgl.choices.get(int(i)) if i.isdigit() else msgl.choices.get(i) for i in msgl]
return u', '.join([string_type(s) for s in msg_list])
+ if sys.version_info < (3,):
+ def __unicode__(self, msgl):
+ return self.__str__(msgl)
+
class MultiSelectField(models.CharField):
""" Choice values can not contain commas. """
From 9f8251b8c3072bffa94c6ceff02d58521b1809a2 Mon Sep 17 00:00:00 2001
From: Tomas
Date: Wed, 25 Sep 2019 07:42:08 +0200
Subject: [PATCH 08/10] Fixing tests
---
.gitignore | 2 ++
example/app/test_msf.py | 2 +-
example/example/settings.py | 2 +-
example/example/urls.py | 5 -----
4 files changed, 4 insertions(+), 7 deletions(-)
diff --git a/.gitignore b/.gitignore
index a7f7aeb..1833915 100644
--- a/.gitignore
+++ b/.gitignore
@@ -10,3 +10,5 @@ dist
.coverage*
.env
example/example.db
+.tox
+
diff --git a/example/app/test_msf.py b/example/app/test_msf.py
index ccec10e..ca121e7 100644
--- a/example/app/test_msf.py
+++ b/example/app/test_msf.py
@@ -146,7 +146,7 @@ def test_named_groups_form(self):
"""""")
actual_html = form.as_p()
- if (1, 11) <= VERSION < (2, 0):
+ if (1, 11) <= VERSION:
# Django 1.11+ does not assign 'for' attributes on labels if they
# are group labels
expected_html = expected_html.replace('label for="id_published_in_0"', 'label')
diff --git a/example/example/settings.py b/example/example/settings.py
index cf50cf4..ff2e5d0 100644
--- a/example/example/settings.py
+++ b/example/example/settings.py
@@ -181,7 +181,7 @@
'django.contrib.messages',
'django.contrib.staticfiles',
# Uncomment the next line to enable the admin:
- 'django.contrib.admin',
+ # 'django.contrib.admin',
# Uncomment the next line to enable admin documentation:
# 'django.contrib.admindocs',
diff --git a/example/example/urls.py b/example/example/urls.py
index 434007f..77c7f6a 100644
--- a/example/example/urls.py
+++ b/example/example/urls.py
@@ -16,7 +16,6 @@
from django import VERSION
from django.conf import settings
-from django.contrib import admin
from django.views.static import serve
@@ -41,8 +40,6 @@ def patterns(prefix, *args):
from django.urls import include, url
-admin.autodiscover()
-
js_info_dict = {
'packages': ('django.conf',),
}
@@ -51,7 +48,6 @@ def patterns(prefix, *args):
urlpatterns = patterns(
'',
url(r'^', include('app.urls')),
- url(r'^admin/', include(admin.site.urls)),
)
urlpatterns += patterns(
'',
@@ -60,7 +56,6 @@ def patterns(prefix, *args):
else:
urlpatterns = [
url(r'^', include('app.urls')),
- url(r'^admin/', admin.site.urls),
url(
r'^%s(?P.*)$' % settings.MEDIA_URL[1:],
serve,
From 3a0d70633fde4037feaa68a07190d085bfdf93f9 Mon Sep 17 00:00:00 2001
From: Tomas
Date: Wed, 25 Sep 2019 09:47:44 +0200
Subject: [PATCH 09/10] Fix matrix versions
---
.travis.yml | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/.travis.yml b/.travis.yml
index a02855a..5acb9b9 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -24,6 +24,10 @@ matrix:
env: DJANGO_VERSION='https://github.com/django/django/archive/master.tar.gz'
- python: "2.7"
env: DJANGO_VERSION='Django>=2.1,<2.2'
+ - python: "2.7"
+ env: DJANGO_VERSION='Django>=2.0,<2.1'
+ - python: "2.7"
+ env: DJANGO_VERSION='Django>=1.6,<1.7'
- python: "3.4"
env: DJANGO_VERSION='Django>=1.4,<1.5'
- python: "3.4"
From dd8590dac54e4e050fc396d38c3962278c35335f Mon Sep 17 00:00:00 2001
From: Tomas
Date: Wed, 2 Oct 2019 06:33:33 +0200
Subject: [PATCH 10/10] Update info for release
---
CHANGES.rst | 13 +++++++++++--
README.rst | 2 +-
setup.py | 2 +-
3 files changed, 13 insertions(+), 4 deletions(-)
diff --git a/CHANGES.rst b/CHANGES.rst
index 197d7b3..12e1fc0 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -1,3 +1,12 @@
+0.1.9 (2019-10-02)
+------------------
+
+* Added support for Django 2
+* Added support for Python 3.6
+* Drop support for Python (2.6, 3.3)
+* Thanks to:
+ * `hirokinko `_
+
0.1.6 (2017-05-10)
------------------
@@ -64,7 +73,7 @@
* Test/example project
* Now works if the first composant of the list of tuple is an integer
-* Now max_length is not required, the Multiselect field calculate it automatically.
+* Now max_length is not required, the Multiselect field calculate it automatically.
* The max_choices attr can be a attr in the model field
* Refactor the code
* Spanish translations
@@ -88,4 +97,4 @@
0.0.1 (2012-09-27)
------------------
-* Initial version from the next `snippet `_
\ No newline at end of file
+* Initial version from the next `snippet `_
diff --git a/README.rst b/README.rst
index fb5d7ac..5eaa059 100644
--- a/README.rst
+++ b/README.rst
@@ -14,7 +14,7 @@ A new model field and form field. With this you can get a multiple select from a
This egg is inspired by this `snippet `_.
-Supported Python versions: 2.6, 2.7, 3.3+
+Supported Python versions: 2.7, 3.4+
Supported Django versions: 1.4-2.0+
diff --git a/setup.py b/setup.py
index c5bba96..98185c4 100644
--- a/setup.py
+++ b/setup.py
@@ -31,7 +31,7 @@ def read(*rnames):
setup(
name="django-multiselectfield",
- version="0.1.8",
+ version="0.1.9",
author="Pablo Martin",
author_email="goinnn@gmail.com",
description="Django multiple select field",