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 @@ else: 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 @@ class MultiSelectTestCase(TestCase): # 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 @@ class MultiSelectTestCase(TestCase): 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): + 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 @@ INSTALLED_APPS = ( '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 @@ except ImportError: # Django < 1.4 from django.urls import include, url -admin.autodiscover() - js_info_dict = { 'packages': ('django.conf',), } @@ -51,7 +48,6 @@ if VERSION < (1, 11): urlpatterns = patterns( '', url(r'^', include('app.urls')), - url(r'^admin/', include(admin.site.urls)), ) urlpatterns += patterns( '', @@ -60,7 +56,6 @@ if VERSION < (1, 11): 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",