<commit_before>Django compatibility
====================

This package has been tested with:

* Django versions 1.4, 1.5, 1.6 and 1.7
* Python versions 2.6, 2.7, 3.3 and 3.4

.. _orm-restrictions:

Using multiple ``filter()`` calls
---------------------------------

Since translated fields live in a separate model,
they can be filtered like any normal relation::

    object = MyObject.objects.filter(translations__title='cheese omelet')

    translation1 = myobject.translations.all()[0]

However, if you have to query a language or translated attribute, this should happen in a single query.
That can either be a single
:func:`~django.db.models.query.QuerySet.filter`,
:func:`~parler.managers.TranslatableManager.translated` or
:func:`~parler.managers.TranslatableManager.active_translations`) call::

    from parler.utils import get_active_language_choices

    MyObject.objects.filter(
        translations__language_code__in=get_active_language_choices(),<commit_msg>Fix documentation about Django compatibility<commit_after>Django compatibility
====================

This package has been tested with:

* Django versions 1.5, 1.6, 1.7, 1.8 and 1.9
* Python versions 2.6, 2.7, 3.3 and 3.4

.. _orm-restrictions:

Using multiple ``filter()`` calls
---------------------------------

Since translated fields live in a separate model,
they can be filtered like any normal relation::

    object = MyObject.objects.filter(translations__title='cheese omelet')

    translation1 = myobject.translations.all()[0]

However, if you have to query a language or translated attribute, this should happen in a single query.
That can either be a single
:func:`~django.db.models.query.QuerySet.filter`,
:func:`~parler.managers.TranslatableManager.translated` or
:func:`~parler.managers.TranslatableManager.active_translations`) call::

    from parler.utils import get_active_language_choices

    MyObject.objects.filter(
        translations__language_code__in=get_active_language_choices(),
{'fraction_non_alphanumeric': 0.1419939577039275, 'fraction_numerical': 0.019133937562940583, 'mean_word_length': 4.242744063324539, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5863134', 'n_tokens_mistral': 591, 'n_tokens_neox': 558, 'n_words': 170}