Database Models

class translations.models.Language(*args, **kwargs)[source]

This model stores the project’s available languages. A user may edit languages from the admin interface. At least one language must always be stored in the database. One (and only one) language must always be set as the ‘default’. Methods of this model and other aspects of yawd-translations guarantee that these constraints are always met.

The languages among which a user may choose are those defined in the LANGUAGES django setting.


Return the display name for this language.


Deleting the default language is not allowed.

save(*args, **kwargs)[source]

Override the default save() method to ensure that one and only one default language exists.

class translations.models.Translatable(*args, **kwargs)[source]

This model should be subclassed by models that need multilingual support.

A Translatable object should only define members that are common to all languages. To define multilingual fields, a subclass of the translations.models.Translation model must be implemented.


This default implementation returns the unicode representation of the related translations.models.Translation object for the current language.


Get the related translations.models.Translation object’s display name for a given language.

save(*args, **kwargs)[source]

Clear prefetched translations


Get translation for the language language_id. If no argument is given, return the current language translation.

Always use this method if you need to access a translation, since it does not generate extra queries.

class translations.models.Translation(*args, **kwargs)[source]

This model represents the translations of a translations.models.Translatable model. There always exist a ForeignKey to the Translatable object, and the reverse relation should be named ‘translations’.

translations.models.post_delete_language(sender, instance, using, **kwargs)[source]

Signal receiver. Update the supported languages to ensure that a 404 will be raised when requesting the language’s urls

translations.models.pre_delete_language(sender, instance, using, **kwargs)[source]

Signal receiver. Although admin actions make sure the default language will not be deleted, this receiver is still here to prevent 3rd party code from accidentally deleting the default language

Previous topic

Code reference

Next topic


This Page