The translations app defines a Translation model, but for the most part, you shouldn’t have to use that directly. When you want to create a foreign key to the translations table, use translations.fields.TranslatedField. This subclasses Django’s django.db.models.ForeignKey to make it work with our special handling of translation rows.
A minimal Addon model looks like this:
import amo.models
from translations.fields import TranslatedField
class Addon(amo.models.ModelBase):
name = TranslatedField()
description = TranslatedField()
If you need to create new Translations without the automagic helpers behind TranslatedField, use Translation.new.
Jumps through all the right hoops to create a new translation.
If id is not given a new id will be created using translations_seq. Otherwise, the id will be used to add strings to an existing translation.
A foreign key to the translations table.
If require_locale=False, the fallback join will not use a locale. Instead, we will look for 1) a translation in the current locale and 2) fallback with any translation matching the foreign key.
Translation model.
Use translations.fields.TranslatedField instead of a plain foreign key to this model.
The translations_seq table, so syncdb will create it during testing.