Releases: KristianOellegaard/django-hvad
Version 2.0.0-beta
Python and Django versions supported:
- Django 2.1 and newer.
- Python 3.5 and newer.
- Older versions are not supported. Please stick to 1.8.0 for older versions.
This is a major release with breaking changes. Please see the migration guide.
Major changes:
- Query engine was refactored to use a parameterized
JOIN
clause. - Translation caching now works with Django API.
- Automatic loading has been removed, in favor of upfront caching of translations.
- Introspection API was reworked (see the new translations accessor).
As many changes have been introduced, this release might introduce more bugs than usual, which
is why it is flagged as beta.
Version 1.8.0
Python and Django versions supported:
- Support for Django 1.10 was added.
- Django 1.7 is no longer supported.
- So, as a reminder, supported Django versions for this release are:
1.8 LTS, 1.9, 1.10.x (for x ≥ 1) and 1.11.
New features:
- Automatic loading of translations on attribute access can now be disabled, by setting
HVAD["AUTOLOAD_TRANSLATIONS"]
toFalse
. This will prevent hvad from initiating database queries. Accessing translatable attributes with no translation loaded will then raise anAttributeError
. - It is possible to automatically install
TranslationQueryset
as the default queryset for all translatable models, by settingHVAD["USE_DEFAULT_QUERYSET"]
toTrue
. Specifically, it changesTranslationManager.default_class
to be aTranslationQueryset
instead of Django'sQuerySet
.
See the section about overriding the default queryset for advantages and caveats of doing so. - Field declaration for internal
language_code
attribute can be overriden. — #332.
Compatibility warnings:
- All settings have been moved to a unique
HVAD
dictionary. Please update your django settings accordingly. - Deprecated class
FallbackQueryset
has been removed. Using it along withuse_fallbacks()
did not work on Django 1.9 and newer and was deprecated on older versions. Using it without that method made it behave like a regular queryset. So as a summary,- Code using
.untranslated().use_fallbacks()
must be replaced with.language().fallbacks()
. - All other uses of
FallbackQueryset
can be safely replaced with a regular DjangoQuerySet
.
- Code using
- Translated admin no longer shows objects lacking a translation. This was already the case on Django 1.9 and newer, and this behavior now extends to all Django versions. Such objects should not happen anyway, and throw a warning when encountered.
Fixes:
- Increase speed of translated attribute access by ~30%, by avoiding a method call when a translation is loaded.
- Attempting to use a reserved name for a translated field now raises an
ImproperlyConfigured
exception instead of silently ignoring the field. - Instances created by serializers using REST
TranslatableModelMixin
in normal, non-enforcing mode can no longer be created without a translation — #322.
Version 1.7.0
New features:
- Support for
defer()
andonly
was added. Note that deferring
all translated fields will not result in translation being skipped,
because 1) it needs to be inspected for language resolution and 2) loaded
translation language must be fixed at query time.
Support is limited to immediate fields at the moment, ie it is not possible
to defer fields of additionals models loaded throughselect_related()
.
Compatibility warnings:
- Internal admin method
TranslatableAdmin.get_available_languages()
is deprecated and will be removed. UseTranslatableModel.get_available_languages()
instead. - Internal admin method
TranslatableAdmin.get_language_tabs()
signature changed.
Fixes:
- Do not consider annotations when looking up translatable query fields.
Fixes errors that could arise when using some annotation names.
— #303. - Accept special value
__all__
for form field list, as a synonym forNone
,
meaning include all known fields. — #313. - Fix translation deletion links that were improperly generated when using inline
change forms. — #317.
Version 1.6.0
Python and Django versions supported:
- Support for Django 1.10 was added. It requires version 1.10.1 or better.
- So, as a reminder, supported Django versions for this release are: 1.7, 1.8 LTS, 1.9, 1.10.x (for x ≥ 1).
Fixes:
- No longer set
master
toNULL
before clearing translations when usingdelete_translations
. This only triggers one query instead of two, and allows enforcing non-null foreign key at the database level. - Django system checks are now run in the test suite in addition to hvad's tests.
Version 1.5.1
Version 1.5.0
Python and Django versions supported:
- Django 1.4 LTS is no longer supported.
- So, as a reminder, supported Django versions for this release are: 1.7, 1.8 LTS, 1.9.
New features:
- It is now possible to specify a custom translation base
model, allowing advanced translation manipulation, such as controlling their loading
withModel.from_db()
. - Translated model's
save()
method now accepts translated field
names inupdate_fields
. Also, if only translated fields, or only untranslated fields
are specified inupdate_fields
, the extra query will be skipped. - Support for third parameter on
ModelAdmin
's
get_object
method was added. - Experimental support for using
language('all')
together with
select_related()
is being introduced. Please
check the generated queries if you use it. Feedback is appreciated.
Compatibility Warnings:
- Saving of translations now happens in the model's
save()
method.
It used to happen in thepost_save
signal. TranslationsMixin
now splits the update intoupdate
andupdate_translation
methods.
The former is called once per save, and uses the latter as many times as required to update
all translations.
Version 1.4.0
Python and Django versions supported:
- Support for Python 3.5 was added.
- Support for Django 1.9 was added.
- Django 1.6 is no longer officially supported.
- Django 1.4 LTS has reached its end of life, and support will be dropped in hvad 1.5.
- So, as a reminder, supported versions for this release are: 1.4 LTS, 1.7, 1.8 LTS, 1.9.
Compatibility Warnings:
- As a result of the annotations fix (see below), applications that worked around
QuerySet.annotate
's shortcomings on translation
querysets are likely to break, asannotate()
has been fixed. The
workarounds should be simply removed. - Method
FallbackQueryset.use_fallbacks()
is not supported on Django 1.9 and newer (and deprecated on other versions, see
below). Please useTranslationQueryset.fallbacks()
instead. - Translated admin no longer shows objects lacking a translation, starting from
Django 1.9. This behavior will be extended to all Django versions in the next release.
Such objects should not happen anyway, and throw a warning when encountered. - Translation model building has been refactored. It is functionally equivalent to its previous
implementation (it passes the exact same test suite), but code depending on the internals
and inner implementation details could break.
Deprecation List:
- Method
FallbackQueryset.use_fallbacks()
is now deprecated on Django 1.6 and newer. The plan is to completely drop
FallbackQueryset
in the near future, and let
TranslationManager.untranslated()
default to returning a plain Django queryset, thus enabling
MyModel.objects.untranslated()
to give access to all features a plain
Django queryset supports.
For queries that need fallbacks, theuse_fallbacks()
method has long been
superseded byTranslationQueryset.fallbacks()
, which is
better tested, uses simpler code yet supports more features.
Please update your queries accordingly:
MyModel.objects.untranslated().use_fallbacks('en', 'ja', 'fr')
should be
rewritten asMyModel.objects.language('en').fallbacks('ja', 'fr')
, or even
MyModel.objects.language().fallbacks()
to have the query use your application's
language settings automatically.
Fixes:
- Annotations added to a
TranslationQueryset
using the
QuerySet.annotate
method no longer end up on
the translation cache with amaster__
prefix. - Specifying translation fields in
unique_together
on translatable models
no longer causes Django to generate incorrect migrations. — #260. - When no
Meta
options are set on aTranslatableModelForm
,
the auto-created one now correctly inherits that of its first base class that
has one set — #262. - Using
language('all')
together withvalues()
no longer breaks — #264.
Version 1.3.0
This release is a collection of fixes and improvements, some of which may introduce minor compatibility issues. Please make sure you fix any deprecation warnings before upgrading to avoid those issues.
Python and Django versions supported:
- Django 1.5 is no longer officially supported.
- Django 1.6 has reached its end of life, and support will be dropped in hvad 1.4.
- As a reminder, Django 1.4 is still supported, so supported versions for this release are: 1.4, 1.6, 1.7, 1.8.
New Features:
- Russian and Latvian translations are now included, thanks to Juris Malinens — #248.
Compatibility Warnings: deprecated features pending removal in 1.3 have been removed. Most notably:
- Calling
save()
on an invalid form now raises an assertion exception. - Classes
TranslatableModelBase
,TranslationFallbackManager
,TranslatableBaseView
and methodTranslationManager.using_translations()
no longer exist. - Deprecated view methods and context modifiers now raise an assertion exception.
Fixes:
- Lift Django restrictions on translated fields in
Meta.unique_together
andMeta.index_together
— #252. - Properly forward model validation methods to translation validation methods, so that model validation detects constraint violations on the translation as well. Fixes duplicate detection in admin for unique constraints on translations — #251.
- Detect name clash between translated and non-translated fields — #240.
- Validate that at least one translation is provided when deserializing objects in
TranslationsMixin
— #256. - Fix handling of model edition from an admin popup in Django 1.7 and newer — #253.
- Generate proper ORM structures for fallbacks. Avoids table relabeling breaking queries, for instance when using
update()
or feeding a queryset to another queryset — #250.
Version 1.2.2
Fixes:
- Properly handle
language_code
inMeta.unique_together
andMeta.index_together
— #244.
Version 1.2.1
Fixes:
- Make passing the
model
argument to queryset's__init__
optional. Still
allow it to be passed either as a positional or named argument — #241.