Skip to content

Commit

Permalink
Dropping django 1.9 and 1.10 and set proper 2.0 version (#31)
Browse files Browse the repository at this point in the history
* Dropping old django: WIP 1/n

* Second pass of django version dropping cleanup
  • Loading branch information
jieter authored Dec 2, 2017
1 parent 344222e commit 37db54b
Show file tree
Hide file tree
Showing 14 changed files with 22 additions and 83 deletions.
5 changes: 1 addition & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,17 @@ script:

matrix:
include:
- { python: 2.7, env: TOXENV=py27-1.10 }
- { python: 2.7, env: TOXENV=py27-1.11 }
- { python: 3.4, env: TOXENV=py34-1.10 }
- { python: 3.4, env: TOXENV=py34-1.11 }
- { python: 3.4, env: TOXENV=py34-2.0 }
- { python: 3.5, env: TOXENV=py35-1.10 }
- { python: 3.5, env: TOXENV=py35-1.11 }
- { python: 3.5, env: TOXENV=py35-2.0 }
- { python: 3.5, env: TOXENV=py35-master }
- { python: 3.6, env: TOXENV=py36-2.0 }
- { python: 3.6, env: TOXENV=py36-master }
- { python: 3.5, env: TOXENV=isort }
- { python: 3.5, env: TOXENV=migrate }
- { python: 2.7, env: TOXENV=docs }
- { python: 3.6, env: TOXENV=docs }

# we allow failures for versions which are not yet released:
allow_failures:
Expand Down
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# django-modeltrans change log

## master

- Dropped support for Django 1.9 and 1.10.

## 0.2.0 (2017-11-13)
- No annotations are made while ordering anymore, instead, expressions are passed onto the original `order_by()` method.
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ Translates Django model fields in a `JSONField` using a registration approach.
# Features/requirements

- Uses one `django.contrib.postgres.JSONField` (PostgreSQL jsonb field) per model.
- Django 1.9, 1.10, 1.11 (with their supported python versions)
- PostgreSQL >= 9.4 and Psycopg2 >= 2.5.4.
- Django 1.11, 2.0 (with their supported python versions)
- PostgreSQL >= 9.5 and Psycopg2 >= 2.5.4.
- [Available on pypi](https://pypi.python.org/pypi/django-modeltrans)
- [Documentation](http://django-modeltrans.readthedocs.io/en/latest/)

Expand Down
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

project = 'django-modeltrans'
with open('../modeltrans/__init__.py', 'rb') as f:
release = re.search('__version__ = \'(.+?)\'', f.read()).group(1)
release = str(re.search('__version__ = \'(.+?)\'', f.read().decode('utf-8')).group(1))
version = release.rpartition('.')[0]


Expand Down
6 changes: 3 additions & 3 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ django-modeltrans - Translate model fields using a `JSONField`
==============================================================

- Uses one `django.contrib.postgres.JSONField` (PostgreSQL jsonb field) for every record.
- Django 1.9, 1.10, 1.11
- PostgreSQL >= 9.4 and Psycopg2 >= 2.5.4.
- Django 1.11 and 2.0 (with their supported python versions)
- PostgreSQL >= 9.5 and Psycopg2 >= 2.5.4.

About the app:

- `Available on pypi <https://pypi.python.org/pypi/django-modeltrans>`_
- Tested with python 2.7, 3.3, 3.4, 3.5 and Django 1.8, 1.9, `Travis CI <https://travis-ci.org/zostera/django-modeltrans>`_
- Tested using `Travis CI <https://travis-ci.org/zostera/django-modeltrans>`_
- `Documentation on readthedocs.org <https://django-modeltrans.readthedocs.io/en/latest/>`_
- `Bug tracker <http://github.com/zostera/django-modeltrans/issues>`_

Expand Down
11 changes: 0 additions & 11 deletions docs/pages/management.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,3 @@ Only to migrate data from the fields managed by django-modeltranslation to
the JSON field managed by django-modeltrans.

Explained in more detail in :ref:`modeltranslation_migration`


.. _add_gin_index:

Adding GIN indexes to the JSON field
------------------------------------

Syntax: ``./manage.py i18n_make_indexes <apps>``

In Django 1.11 and later, a GIN index is automatically added with the
``i18n``-field. For 1.9 and 1.10 you can use this command.
4 changes: 2 additions & 2 deletions docs/pages/performance.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ Adding gin indexes
++++++++++++++++++

In order to perform well while performing filtering or ordering on translated values,
the ``i18n``-field need a GIN index. For django 1.11 and later, the index is added
automatically, for django 1.9 and 1.10, refer to :ref:`add_gin_index`.
the ``i18n``-field need a GIN index. The index is added automatically, for every
supported Django version.
3 changes: 1 addition & 2 deletions docs/pages/settings.rst
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ If configured like this::
-------------------------
Boolean signalling django-modeltrans to create a `GinIndex <https://docs.djangoproject.com/en/stable/ref/contrib/postgres/indexes/#ginindex>`_
for each ``i18n`` field.
Support for ``GinIndex`` is added in django 1.11, for previous versions,
use :ref:`add_gin_index`.
Can be disabled to allow customization.

``True`` by default.
1 change: 1 addition & 0 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
Sphinx==1.6.2
Django
sphinx_rtd_theme
recommonmark
psycopg2
39 changes: 0 additions & 39 deletions modeltrans/compat.py

This file was deleted.

14 changes: 4 additions & 10 deletions modeltrans/fields.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
# -*- coding: utf-8 -*-

from django.contrib.postgres.fields import JSONField
from django.contrib.postgres.fields.jsonb import JSONField, KeyTextTransform
from django.core.exceptions import ImproperlyConfigured
from django.db.models import fields
from django.db.models.functions import Cast, Coalesce
from django.utils.translation import ugettext as _

from .compat import KeyTextTransform
from .conf import get_create_gin_setting, get_default_language, get_fallback_chain
from .utils import build_localized_fieldname, get_i18n_index_name, get_language

Expand Down Expand Up @@ -249,13 +248,8 @@ def contribute_to_class(self, cls, name):
raise ImproperlyConfigured('{} must have name "i18n"'.format(self.__class__.__name__))

if get_create_gin_setting():
# If used with Django 1.11 and later, this will add a GinIndex() for the i18n column.
try:
from django.contrib.postgres.indexes import GinIndex
index_name = get_i18n_index_name(cls)
cls._meta.indexes.append(GinIndex(fields=['i18n'], name=index_name))
except ImportError: # noqa
# remove if support for django 1.9 and 1.10 is dropped.
pass
from django.contrib.postgres.indexes import GinIndex
index_name = get_i18n_index_name(cls)
cls._meta.indexes.append(GinIndex(fields=['i18n'], name=index_name))

super(TranslationField, self).contribute_to_class(cls, name)
4 changes: 2 additions & 2 deletions modeltrans/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ def annotate(self, *args, **kwargs):
'''
Patch annotate to allow the use of translated field names in annotations.
https://docs.djangoproject.com/en/1.11/ref/models/querysets/#annotate
https://docs.djangoproject.com/en/stable/ref/models/querysets/#annotate
'''
args = [self._rewrite_expression(a) for a in args]
kwargs = {alias: self._rewrite_expression(expr) for alias, expr in kwargs.items()}
Expand All @@ -256,7 +256,7 @@ def create(self, **kwargs):
Patch the create method to allow adding the value for a translated field
using `Model.objects.create(..., title_nl='...')`.
https://docs.djangoproject.com/en/1.11/ref/models/querysets/#create
https://docs.djangoproject.com/en/stable/ref/models/querysets/#create
'''
return super(MultilingualQuerySet, self).create(
**transform_translatable_fields(self.model, kwargs)
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
packages=find_packages(exclude=['tests.*', 'tests', 'example.*', 'example']),
include_package_data=True, # declarations in MANIFEST.in

install_requires=['Django>=1.10'],
install_requires=['Django>=1.11'],

classifiers=[
'Environment :: Web Environment',
Expand Down
8 changes: 3 additions & 5 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
[tox]
args_are_paths = false
envlist =
{py27,py34,py35}-{1.9,1.10,1.11},
{py27,py34,py35}-{1.11},
{py34,py35,py36}-{2.0},
{py35,py36}-{master},
migrate
Expand All @@ -26,10 +26,8 @@ commands =
coverage run ./manage.py test --no-input
coverage html
deps =
1.9: Django>=1.9,<1.10
1.10: Django>=1.10,<1.11
1.11: Django>=1.11,<2.0
2.0: Django==2.0b1
2.0: Django>=2.0,<2.1
master: https://github.com/django/django/archive/master.tar.gz
psycopg2
coverage
Expand Down Expand Up @@ -67,7 +65,7 @@ basepython = python3.5
commands = make isort

[testenv:docs]
basepython = python2.7
basepython = python3.6
whitelist_externals = make
changedir = docs
commands = make html
Expand Down

0 comments on commit 37db54b

Please sign in to comment.