26 Commits
v5.0a7 ... v5.4

Author SHA1 Message Date
Swen Kooij
893fe0f5ab Bump version to 5.4 2019-08-14 08:58:08 +03:00
Swen Kooij
3de1492a58 Use collections.abc.Iterable instead of collections.Iterable
The latter is going to be removed after Python 3.8
2019-08-14 08:57:05 +03:00
Swen Kooij
946e9a67c4 Bump version to 5.3 2019-06-28 08:31:31 +03:00
Swen Kooij
36f6e946b0 Attempt at reducing deprecation warning spam 2019-06-27 15:15:44 +03:00
Swen Kooij
909ebfee69 Bump version number to 5.2 2019-06-27 14:53:58 +03:00
Swen Kooij
95284e6fd0 Add extra step to set up instructions about applying migrations 2019-06-27 13:42:42 +03:00
Swen Kooij
e84a5e4ff1 Bump version to 5.1 2019-06-27 13:37:28 +03:00
Swen Kooij
472c7bbc41 Remove dead travis-ci configuration 2019-06-27 13:36:23 +03:00
Swen Kooij
8cc50889ec Set version back to 5.0a11, it was never released 2019-06-27 13:30:19 +03:00
Swen Kooij
8494615d05 Upgrade django-postgres-extra to 1.22 2019-06-27 13:28:29 +03:00
Swen Kooij
f0541c047b Bump version number to 5.0a12 2019-06-27 13:27:59 +03:00
Swen Kooij
84658f6010 Bump version number to 5.0a10 2019-06-05 23:26:47 +03:00
Swen Kooij
0e29871458 Merge pull request #62 from GabLeRoux/patch-1
Remove extra dot in example integration code
2019-06-05 23:12:43 +03:00
Swen Kooij
ffe235d3ac Merge pull request #66 from martinsvoboda/admin-widget-image
Added the image of admin widget
2019-06-05 23:12:25 +03:00
Swen Kooij
d7db2c58c0 Merge pull request #68 from MELScience/fix-django-22
update to support Django 2.2
2019-06-05 23:11:38 +03:00
Dmitry Groshev
6a7545a910 update to support Django 2.2 2019-05-30 13:11:33 +01:00
Martin Svoboda
11bf4ee88a Added the image of admin widget 2019-05-26 11:12:45 +02:00
Gabriel Le Breton
d3223eca53 Remove extra dot in example integration code 2019-04-23 11:12:29 -04:00
Swen Kooij
f0ac0f7f25 Merge branch 'bump-version' 2019-02-21 12:54:04 +02:00
Swen Kooij
93ffce557c Bump version number to 5.0a9 2019-02-21 12:50:58 +02:00
Swen Kooij
7c432baec7 Upgrade django-postgres-extra to 1.21a16 2019-02-21 12:50:46 +02:00
Swen Kooij
476a20ba88 Merge pull request #61 from SectorLabs/bump-version
Bump version number to 5.0a8
2019-02-21 12:47:15 +02:00
Swen Kooij
ad99b77bcd Bump version number to 5.0a8 2019-02-21 12:34:22 +02:00
Swen Kooij
151250505d Merge pull request #60 from AdrianMuntean/error_on_empty_localized_integer_field
Return empty string in case the LocalizedIntegerField is null
2019-02-21 12:31:50 +02:00
Adrian Muntean
d8b872758c Return empty string in case of None 2019-02-20 12:26:04 +02:00
Adrian Muntean
a0ca977cab Set None in case the LocalizedIntegerField is null
In case the LocalizedIntegerField is null in the DB then it must explicitly be set to None,
otherwise it will yield TypeError: __str__ returned non-string
2019-02-14 14:48:38 +02:00
10 changed files with 51 additions and 32 deletions

View File

@@ -1,18 +0,0 @@
env:
- DJANGO_SETTINGS_MODULE=settings
sudo: true
before_install:
- sudo apt-get update -qq
- sudo apt-get install -qq build-essential gettext python-dev zlib1g-dev libpq-dev xvfb
- sudo apt-get install -qq libtiff4-dev libjpeg8-dev libfreetype6-dev liblcms1-dev libwebp-dev
- sudo apt-get install -qq graphviz-dev python-setuptools python3-dev python-virtualenv python-pip
- sudo apt-get install -qq firefox automake libtool libreadline6 libreadline6-dev libreadline-dev
- sudo apt-get install -qq libsqlite3-dev libxml2 libxml2-dev libssl-dev libbz2-dev wget curl llvm
language: python
python:
- "3.5"
services:
- postgresql
install: "pip install -r requirements/test.txt"
script:
- coverage run manage.py test

View File

@@ -33,7 +33,7 @@ Installation
.. code-block:: bash .. code-block:: bash
INSTALLED_APPS = [ INSTALLED_APPS = [
.... ...
'django.contrib.postgres', 'django.contrib.postgres',
'localized_fields.apps.LocalizedFieldsConfig' 'localized_fields.apps.LocalizedFieldsConfig'
@@ -61,6 +61,13 @@ Installation
('ro', 'Romanian') ('ro', 'Romanian')
) )
4. Apply migrations to enable the HStore extension:
.. code-block:: bash
python manage.py migrate
Usage Usage
----- -----
@@ -279,7 +286,7 @@ Besides ``LocalizedField``, there's also:
Allows storing integers in multiple languages. This works exactly like ``LocalizedField`` except that Allows storing integers in multiple languages. This works exactly like ``LocalizedField`` except that
all values must be integers. Do note that values are stored as strings in your database because all values must be integers. Do note that values are stored as strings in your database because
the backing field type is ``hstore``, which only allows storing integers. The ``LocalizedIntegerField`` the backing field type is ``hstore``, which only allows storing strings. The ``LocalizedIntegerField``
takes care of ensuring that all values are integers and converts the stored strings back to integers takes care of ensuring that all values are integers and converts the stored strings back to integers
when retrieving them from the database. Do not expect to be able to do queries such as: when retrieving them from the database. Do not expect to be able to do queries such as:
@@ -369,6 +376,10 @@ To enable widgets in the admin, you need to inherit from ``LocalizedFieldsAdminM
admin.site.register(MyLocalizedModel, MyLocalizedModelAdmin) admin.site.register(MyLocalizedModel, MyLocalizedModelAdmin)
.. image:: ./images/admin-widget.png
:alt: The appearance of admin widget
Frequently asked questions (FAQ) Frequently asked questions (FAQ)
-------------------------------- --------------------------------

BIN
images/admin-widget.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 57 KiB

View File

@@ -22,6 +22,7 @@ class LocalizedFieldsAdminMixin:
} }
js = ( js = (
'admin/js/jquery.init.js',
'localized_fields/localized-fields-admin.js', 'localized_fields/localized-fields-admin.js',
) )

View File

@@ -17,17 +17,17 @@ class LocalizedAutoSlugField(LocalizedField):
"""Automatically provides slugs for a localized """Automatically provides slugs for a localized
field upon saving.""" field upon saving."""
warnings.warn(
'LocalizedAutoSlug is deprecated and will be removed in the next major version.',
DeprecationWarning
)
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
"""Initializes a new instance of :see:LocalizedAutoSlugField.""" """Initializes a new instance of :see:LocalizedAutoSlugField."""
self.populate_from = kwargs.pop('populate_from', None) self.populate_from = kwargs.pop('populate_from', None)
self.include_time = kwargs.pop('include_time', False) self.include_time = kwargs.pop('include_time', False)
warnings.warn(
'LocalizedAutoSlug is deprecated and will be removed in the next major version.',
DeprecationWarning
)
super(LocalizedAutoSlugField, self).__init__( super(LocalizedAutoSlugField, self).__init__(
*args, *args,
**kwargs **kwargs

View File

@@ -1,7 +1,8 @@
import deprecation import deprecation
import collections
from typing import Optional from typing import Optional
from collections.abc import Iterable
from django.conf import settings from django.conf import settings
from django.utils import translation from django.utils import translation
@@ -97,7 +98,7 @@ class LocalizedValue(dict):
lang_value = value.get(lang_code, self.default_value) lang_value = value.get(lang_code, self.default_value)
self.set(lang_code, lang_value) self.set(lang_code, lang_value)
elif isinstance(value, collections.Iterable): elif isinstance(value, Iterable):
for val in value: for val in value:
self._interpret_value(val) self._interpret_value(val)
@@ -233,4 +234,4 @@ class LocalizedIntegerValue(LocalizedValue):
"""Returns string representation of value""" """Returns string representation of value"""
value = self.translate() value = self.translate()
return str(value) if value is not None else None return str(value) if value is not None else ''

View File

@@ -1,2 +1,2 @@
django-postgres-extra==1.21a9 django-postgres-extra==1.22
deprecation==2.0.3 deprecation==2.0.3

View File

@@ -24,10 +24,33 @@ INSTALLED_APPS = (
'django.contrib.auth', 'django.contrib.auth',
'django.contrib.contenttypes', 'django.contrib.contenttypes',
'django.contrib.admin', 'django.contrib.admin',
'django.contrib.messages',
'localized_fields', 'localized_fields',
'tests', 'tests',
) )
TEMPLATES = [
{
"BACKEND": "django.template.backends.django.DjangoTemplates",
"DIRS": [],
"APP_DIRS": True,
"OPTIONS": {
"context_processors": [
"django.template.context_processors.debug",
"django.template.context_processors.request",
"django.contrib.auth.context_processors.auth",
"django.contrib.messages.context_processors.messages",
],
},
},
]
MIDDLEWARE = [
'django.contrib.messages.middleware.MessageMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
]
# set to a lower number than the default, since # set to a lower number than the default, since
# we want the tests to be fast, default is 100 # we want the tests to be fast, default is 100
LOCALIZED_FIELDS_MAX_RETRIES = 3 LOCALIZED_FIELDS_MAX_RETRIES = 3

View File

@@ -33,7 +33,7 @@ with open(os.path.join(os.path.dirname(__file__), 'README.rst'), encoding='utf-8
setup( setup(
name='django-localized-fields', name='django-localized-fields',
version='5.0a7', version='5.4',
packages=find_packages(exclude=['tests']), packages=find_packages(exclude=['tests']),
include_package_data=True, include_package_data=True,
license='MIT License', license='MIT License',
@@ -44,7 +44,7 @@ setup(
author_email='open-source@sectorlabs.ro', author_email='open-source@sectorlabs.ro',
keywords=['django', 'localized', 'language', 'models', 'fields'], keywords=['django', 'localized', 'language', 'models', 'fields'],
install_requires=[ install_requires=[
'django-postgres-extra>=1.21a15', 'django-postgres-extra>=1.22',
'Django>=1.11', 'Django>=1.11',
'deprecation==2.0.3' 'deprecation==2.0.3'
], ],

View File

@@ -1,11 +1,12 @@
[tox] [tox]
envlist = py35-dj{111,20,21}, py36-dj{111,20,21}, py37-dj{111,20,21} envlist = py35-dj{111,20,21,22}, py36-dj{111,20,21,22}, py37-dj{111,20,21,22}
[testenv] [testenv]
deps = deps =
dj111: Django>=1.11,<1.12 dj111: Django>=1.11,<1.12
dj20: Django>=2.0,<2.1 dj20: Django>=2.0,<2.1
dj21: Django>=2.1,<2.2 dj21: Django>=2.1,<2.2
dj22: Django>=2.2,<2.3
-rrequirements/test.txt -rrequirements/test.txt
setenv = setenv =
DJANGO_SETTINGS_MODULE=settings DJANGO_SETTINGS_MODULE=settings