parler.admin module

Translation support for admin forms.

django-parler provides the following classes:

Admin classes can be created as expected:

from django.contrib import admin
from parler.admin import TranslatableAdmin
from myapp.models import Project

class ProjectAdmin(TranslatableAdmin):
    list_display = ('title', 'status')
    fieldsets = (
        (None, {
            'fields': ('title', 'status'),
    ), ProjectAdmin)

All translated fields can be used in the list_display and fieldsets like normal fields.

While almost every admin feature just works, there are a few special cases to take care of:

See the admin compatibility page for details.

The BaseTranslatableAdmin class

class parler.admin.BaseTranslatableAdmin

The shared code between the regular model admin and inline classes.


The form to use for the model.

alias of TranslatableModelForm

get_form_language(request, obj=None)

Return the current language for the currently displayed object fields.

get_language_tabs(request, obj, available_languages, css_class=None)

Determine the language tabs to show.


Make sure the current language is selected.


Return the language to use in the queryset.

query_language_key = u'language'

The URL parameter for the language value.


Make sure the current language is selected.

The TranslatableAdmin class

class parler.admin.TranslatableAdmin(model, admin_site)

Base class for translated admins.

This class also works as regular admin for non TranslatableModel objects. When using this class with a non-TranslatableModel, all operations effectively become a NO-OP.


The language column which can be included in the list_display. It also shows untranslated languages


Dynamic property to support transition to regular models.

This automatically picks admin/parler/change_form.html when the admin uses a translatable model.

delete_inline_translations = True

Whether translations of inlines should also be deleted when deleting a translation.

delete_model_translation(request, translation)

Hook for deleting a translation. This calls get_translation_objects() to collect all related objects for the translation. By default, that includes the translations for inline objects.

delete_translation(*args, **kwargs)

The ‘delete translation’ admin view for this model.

deletion_not_allowed(request, obj, language_code)

Deletion-not-allowed view.


Fetching the available languages as queryset.

get_form(request, obj=None, **kwargs)

Pass the current language to the form.


Hook for allowing to change the title in the language_column() of the list_display.

get_object(request, object_id, *args, **kwargs)

Make sure the object is fetched in the correct language.

get_translation_objects(request, language_code, obj=None, inlines=True)

Return all objects that should be deleted when a translation is deleted. This method can yield all QuerySet objects or lists for the objects.


Add a delete-translation view.


The language column which can be included in the list_display.

prefetch_language_column = True

Whether the translations should be prefetched when displaying the ‘language_column’ in the list.

render_change_form(request, context, add=False, change=False, form_url=u'', obj=None)

Insert the language tabs.

The TranslatableInlineModelAdmin class

class parler.admin.TranslatableInlineModelAdmin(parent_model, admin_site)

Base class for inline models.


The form to use.

alias of TranslatableModelForm


The formset to use.

alias of TranslatableBaseInlineFormSet

get_available_languages(obj, formset)

Fetching the available inline languages as queryset.

get_form_language(request, obj=None)

Return the current language for the currently displayed object fields.

get_formset(request, obj=None, **kwargs)

Return the formset, and provide the language information to the formset.


Whether to show inline tabs, can be set as attribute on the inline.

The TranslatableStackedInline class

class parler.admin.TranslatableStackedInline(parent_model, admin_site)

The inline class for stacked layout.

The TranslatableTabularInline class

class parler.admin.TranslatableTabularInline(parent_model, admin_site)

The inline class for tabular layout.

The SortedRelatedFieldListFilter class

class parler.admin.SortedRelatedFieldListFilter(*args, **kwargs)

Override the standard RelatedFieldListFilter, to sort the values after rendering their __unicode__() values. This can be used for translated models, which are difficult to sort beforehand. Usage:

from django.contrib import admin
from parler.admin import SortedRelatedFieldListFilter

class MyAdmin(admin.ModelAdmin):

    list_filter = (
        ('related_field_name', SortedRelatedFieldListFilter),