Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Django versions and CI link in README and documentation #95

Merged
merged 5 commits into from
Aug 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
# django-modeltrans

[![Travis CI](https://travis-ci.org/zostera/django-modeltrans.svg?branch=master)](https://travis-ci.org/zostera/django-modeltrans)
[![CI](https://github.com/zostera/django-modeltrans/actions/workflows/ci.yml/badge.svg)](https://github.com/zostera/django-modeltrans/actions/workflows/ci.yml)
[![Documentation Status](https://readthedocs.org/projects/django-modeltrans/badge/?version=latest)](http://django-modeltrans.readthedocs.io/en/latest/?badge=latest)
[![Any color you like](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/ambv/black)

Translates Django model fields in a `JSONField` using a registration approach.

# Features/requirements

- Uses one PostgreSQL `jsonb`-field per model.
(`django.contrib.postgres.JSONField` for Django<3.1, `django.db.models.JSONField` for Django>=3.1)
- Django 2.2, 3.0, 3.1, 3.2, 4.0 (with their supported python versions)
- Uses one PostgreSQL `jsonb`-field per model (via `django.db.models.JSONField`)
- Django 3.2, 4.0, 4.1, 4.2 (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
6 changes: 3 additions & 3 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
django-modeltrans - Translate model fields using a `JSONField`
==============================================================

- Uses one `django.contrib.postgres.JSONField` (PostgreSQL JSONB field) for every record.
- Django 1.11 and 2.0 (with their supported python versions)
- Uses one `django.db.models.JSONField` (PostgreSQL JSONB field) for every record.
- Django Django 3.2, 4.0, 4.1, 4.2 (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 using `Travis CI <https://travis-ci.org/zostera/django-modeltrans>`_
- Tested using `GitHub actions <https://github.com/zostera/django-modeltrans/actions>`_
- `Documentation on readthedocs.org <https://django-modeltrans.readthedocs.io/en/latest/>`_
- `Bug tracker <http://github.com/zostera/django-modeltrans/issues>`_

Expand Down
12 changes: 2 additions & 10 deletions modeltrans/fields.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from django.core.exceptions import ImproperlyConfigured
from django.db.models import F, fields
from django.db.models import F, JSONField, fields
from django.db.models.fields.json import KeyTextTransform
from django.db.models.functions import Cast, Coalesce
from django.utils.translation import gettext

Expand All @@ -11,15 +12,6 @@
get_language,
)

try:
# django==3.1 moved JSONField into django.db.models
from django.db.models import JSONField
from django.db.models.fields.json import KeyTextTransform
except ImportError:
from django.contrib.postgres.fields import JSONField
from django.contrib.postgres.fields.jsonb import KeyTextTransform


SUPPORTED_FIELDS = (fields.CharField, fields.TextField)

DEFAULT_LANGUAGE = get_default_language()
Expand Down
6 changes: 1 addition & 5 deletions modeltrans/utils.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
from django.core.exceptions import FieldDoesNotExist
from django.db.models.constants import LOOKUP_SEP
from django.db.models.fields.json import KeyTransform
from django.db.models.lookups import Transform
from django.utils.translation import get_language as _get_language

from .conf import get_available_languages, get_default_language

try:
from django.db.models.fields.json import KeyTransform
except ImportError:
from django.contrib.postgres.fields.jsonb import KeyTransform


def get_language():
"""
Expand Down
Loading