API documentationο
ParlerAdminWagtailMixin (internal use)ο
β οΈ This mixin is documented for dev only: you SHOULD NOT use it directly β οΈ
- class wagtail_parler.handlers.ParlerAdminWagtailMixinο
Bases:
objectMixin to manage translations via Parler inside a ModelAdmin or SnippetViewSet
You SHOULD NOT use this Mixin directly but ParlerModelAdminMixin or ParlerSnippetAdminMixin
- _set_translations_handlers(handlers: List, base_handler: TranslationsList | None = None) Set[str]ο
Build handler for each locale and add it to handlers list base_handler can be used as a template : all itβs children which are FieldPanel will have their field_name renamed with translations_%(language_code)s_%(field_name)s if they exists in the translation Model.
- get_edit_handler() TabbedInterfaceο
Prepare real handlers to be used with this Model Admin.
ParlerSnippetAdminMixinο
- class wagtail_parler.handlers.ParlerSnippetAdminMixin(**kwargs)ο
Bases:
ParlerAdminWagtailMixin,SnippetViewSetMixin to use with SnippetViewSet to manage parler translations.
If no edit_handler are defined, the default behaviour will create an unstranlated data tab then a tab for each language You can specify your edit_handler to have more control over how form is built. TranslationsList will be duplicated for each language and populated with translations fields if no children are given. Of course, you can also configure fields manually ex:
class SomeModelAdminSnippet(ParlerSnippetAdminMixin, SnippetViewSet): model = SomeModel class FoodAdminSnippet(ParlerSnippetAdminMixin, SnippetViewSet): model = Food edit_handler = ObjectList( children=[ FieldPanel("yum_rating"), TranslationsList( heading="%(code)s: %(locale)s %(status)s", # let children empty, it will be auto populated ), ObjectList( heading=_("RΓ©gime"), children=[FieldPanel("vegetarian"), FieldPanel("vegan")] ), ], )
- get_edit_handler() TabbedInterfaceο
Prepare real handlers to be used with this Model Admin.
ParlerModelAdminMixinο
- class wagtail_parler.handlers.ParlerModelAdminMixinο
Bases:
ParlerAdminWagtailMixinMixin to use with ModelAdmin to manage parler translations. ex:
class SomeModelAdmin(ParlerModelAdminMixin, ModelAdmin): model = SomeModel class FoodModelAdmin(ParlerModelAdminMixin, ModelAdmin): model = Food edit_handler = ObjectList( children=[ FieldPanel("yum_rating"), TranslationsList( heading="%(code)s: %(locale)s %(status)s", # type: ignore # let children empty, it will be auto populated ), ObjectList( heading=_("RΓ©gime"), children=[FieldPanel("vegetarian"), FieldPanel("vegan")] ), ], )
AutoParlerModelFormο
β οΈ This class is documented for dev only: you SHOULD NOT use it directly β οΈ
- class wagtail_parler.forms.AutoParlerModelForm(*args: Tuple, **kwargs: Dict)ο
Bases:
FormManage update/create/delete of translations
- auto_parler_fields: Set[str] = {}ο
- cleaned_data_for_locales: Dict[str, Any] = {}ο
- _init_i18n_initials(instance: Model, initials: Dict) Dict | Noneο
If instance already has translations, populates the initial content of translated fields
- get_localized_fieldnames(locale: str) Generatorο
Generator of (field_name: str, i18n_field_name:str) to get real field_name for the translated model and the current form associated field name.
param: locale: str: locale code of translation to save/create/delete
- _save_locale(locale: str) Tupleο
Depending sent data, will save/create/delete translation for the given language code
- Args:
locale (str): locale code of translation to save/create/delete
- Returns:
- (None|True|False, int|instance|[instances]: for deletion, will return None and the
number of translations deleted for creation, will return True and the created of translation for update, will return False and the updated of translation
- clean() Dictο
Prepare cleaned_data_for_locales of translated fields
- save(*args: Tuple, **kwargs: Dict) Modelο
Save the instance and itβs translations
- base_fields = {}ο
- declared_fields = {}ο
- property mediaο
Return all media required to render the widgets on this form.