Reference: Admin

This module contains the admins for the Translations app.

class translations.admin.TranslatableAdminMixin[source]

An admin mixin which provides custom translation functionalities.

Provides functionalities like prepare_translation_inlines() to prepare the translation inlines of a type in some inlines based on the admin model.

prepare_translation_inlines(inlines, inline_type)[source]

Prepare the translation inlines of a type in some inlines based on the admin model.

Searches the inlines for the translation inlines of the specified inline type and prepares the translation inlines based on the admin model.

Parameters:

To prepare the translation inlines of a type in some inlines based on the admin model:

class TranslationInline(GenericStackedInline):
    """The inline which represents the `Translation` instances."""

    model = Translation
    extra = 1
class TranslatableAdmin(TranslatableAdminMixin, admin.ModelAdmin):
    """The admin which represents the `Translatable` instances."""

    def get_inline_instances(self, request, obj=None):
        inlines = list(
            super(TranslatableAdmin, self).get_inline_instances(request, obj)
        )
        self.prepare_translation_inlines(inlines, TranslationInline)
        return inlines

Note

The code above is exactly how the Translations app makes Django admin translatable. It can be used to make any admin translatable.

Check out How to: Integrate with custom admins.

class translations.admin.TranslatableAdmin[source]

The admin which represents the Translatable instances.

Manages creating, reading, updating and deleting the Translatable instances.

To make an admin translatable:

from translations.admin import TranslatableAdmin, TranslationInline
class ContinentAdmin(TranslatableAdmin):
    inlines = [TranslationInline]
class translations.admin.TranslationInline[source]

The inline which represents the Translation instances.

Manages creating, reading, updating and deleting the Translation instances.

To add translation inlines to a translatable admin:

from translations.admin import TranslatableAdmin, TranslationInline
class ContinentAdmin(TranslatableAdmin):
    inlines = [TranslationInline]