Skip to main content

Brings "omelette du fromage" 🧀 from parler into wagtail 🐦 (via wagtail snippets or modeladmin)

Project description

Wagtail Parler 🧀 🐦

Stable Version Code style: black Checked with mypy Imports: isort semver Documentation Status

Brings "omelette du fromage" 🧀 from parler into wagtail 🐦 for your custom models (via modeladmin or wagtail snippets)

Wagtail Parler Logo

Wagtail Parler helps you to use django-parler inside wagtail to translate your customs models. It works for wagtail-modeladmin (which is now deprectaed) and also the new official way: wagtail's snippets.

Translated and untranslated tabs

Tests, QA, consistency and compatibility

This app is tested to runs with:

  • Django 4.2, 5.2
  • Wagtail 5.0, 5.1, 5.2, 6.3, 7.0
  • Parler 2.3 (probably older ones to, it's just not tested)
  • Python 3.9, 3.11

To ensure code quality and consistency:

Why

There is already an internationalisation support in wagtail via their own language features called wagtail-localize. This app also support wagtail modeladmin. But the approach of wagtail-localize could be unconvenient as translations are stored in the same table than "main instances", resulting specific queryset and managers to manage your models.
For app's like treebeard, it can break the logic of your tree.

For those reasons, you could prefer to use django-parler as translations approach. Wagtail Parler is fit to you: it will allow you to use django-parler to translate your own models and still have a usefull wagtail interface to manage translations (via official wagtail's snippet admin but also with the old wagtail-modeladmin)

Installation

Install the package via pip. We consider you already have django-parler and wagtail installed.

pip install wagtail-parler

Then, in settings.py, add wagtail_parler to the installed apps.

# settings.py

INSTALLED_APPS = [
    # "wagtail.users" # for wagtail >= 7
    # …
    "wagtail_parler",
    # …
]

ATTENTION! Since wagtail 7, you need also to add wagtail.users in the installed app if not already done!

Basic Usage

You just have to add ParlerSnippetAdminMixin to your SnippetViewSet (or ParlerModelAdminMixin to your ModelAdmin), et voilà, you are ready to eat omelette du fromage.

from wagtail.snippets.views.snippets import SnippetViewSet
from wagtail.snippets.models import register_snippet
from wagtail_parler.handlers import ParlerSnippetAdminMixin
from .models import Food


class FoodAdmin(ParlerSnippetAdminMixin, SnippetViewSet):
    model = Food

register_snippet(FoodAdmin)

# or for an usage with wagtail-modeladmin:

from wagtail_modeladmin.options import ModelAdmin, modeladmin_register
from wagtail_parler.handlers import ParlerModelAdminMixin
from .models import Food

class FoodAdmin(ParlerModelAdminMixin, ModelAdmin):
    model = Food

modeladmin_register(FoodAdmin)

Doest it support PreviewableMixin ?

Yes it does. When user change the translation tab, preview is updated with translated data from the form. Same behaviour when a data is updated of course.

Doest it support RevisionMixin ?

Yes it does, but you need to inherit from wagtail_parler.models.WagtailParlerModel instead of parler.models.TranslatableModel. eg:

# Django imports
from django.db import models
from django.utils.translation import gettext_lazy as _

# Third Party
from wagtail.models import RevisionMixin
from wagtail_parler.models import WagtailParlerModel
from parler.models import TranslatedFields


class Food(RevisionMixin, WagtailParlerModel):
    slug = models.SlugField(
        verbose_name=_("Slug"),
        blank=False,
        null=False,
    )
    translations = TranslatedFields(
        name=models.CharField(_("Nom"), max_length=255, blank=False, null=False),
        summary=models.TextField(_("Résumé"), blank=False, null=False),
        content=models.TextField(_("Contenu"), blank=False, null=False),
    )

Extra 🧀🐦

More advanced usage, tests, etc., are documented in the doc.

Maître Wagtail, sur un arbre perché,
Tenait en son bec une omelette du fromage.
Maître Webu, à l'envie de parler,
Lui tint à peu près ce langage :
Et bonjour, Monsieur Wagtail.
Que de beaux commits ! quelle merveille !
Sans mentir, si votre codage
Se rapporte à votre plumage,
Vous êtes le Phénix des hôtes de ces dépots. …

From « Le Corbeau et le Renard » by Jean de La Fontaine, 1668.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

wagtail_parler-0.7.2.tar.gz (27.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

wagtail_parler-0.7.2-py3-none-any.whl (31.1 kB view details)

Uploaded Python 3

File details

Details for the file wagtail_parler-0.7.2.tar.gz.

File metadata

  • Download URL: wagtail_parler-0.7.2.tar.gz
  • Upload date:
  • Size: 27.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for wagtail_parler-0.7.2.tar.gz
Algorithm Hash digest
SHA256 00f43af0abf9593c4a35da400593ae8712400ee1bb04c20dad71f97573a4e1d0
MD5 43e6e59f049f9783fa3a6910af0c4027
BLAKE2b-256 4b83ac132c20707cc1d83719390716f05996b442825b99a19f4be03ff78f3b57

See more details on using hashes here.

File details

Details for the file wagtail_parler-0.7.2-py3-none-any.whl.

File metadata

  • Download URL: wagtail_parler-0.7.2-py3-none-any.whl
  • Upload date:
  • Size: 31.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for wagtail_parler-0.7.2-py3-none-any.whl
Algorithm Hash digest
SHA256 7cf59ad32cecb7b7292b07f41c0a2a283535d9b57cf15b8acbc46590d230d09c
MD5 aca1b7b77bb01a524651d44abc1067ba
BLAKE2b-256 3cd98f5fc3b6621517794a24c36b81124433ff4875162a7c652ab810395948af

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page