Skip to main content
Help us improve PyPI by participating in user testing. All experience levels needed!

A simple Django package for model translations

Project description

This package is based on the translations module from FeinCMS. It offers functions and abstract base classes that can be used to store translated models. There isn’t much magic going on here.

Usage example:

class News(models.Model, TranslatedObjectMixin):
    active = models.BooleanField(default=False)
    created = models.DateTimeField(default=timezone.now)


class NewsTranslation(Translation(News)):
    title = models.CharField(max_length=200)
    body = models.TextField()

Print the titles of all news entries either in the current language (if available) or in any other language:

for news in News.objects.all():
    print news.translation.title

Print all the titles of all news entries which have an english translation:

from django.utils import translation
translation.activate('en')
for news in News.objects.filter(translations__language_code='en'):
    print news.translation.title

Project details


Release history Release notifications

This version
History Node

0.1

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging CloudAMQP CloudAMQP RabbitMQ AWS AWS Cloud computing Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page