Snippets embedder for Wagtail richtext fields
Snippets embedder for Wagtail RichTextField.
Check out Awesome Wagtail for more awesome packages and resources from the Wagtail community.
Install the package with
pip install wagtailembedder
Add wagtailembedder
to your settings.py
in the INSTALLED_APPS
section:
INSTALLED_APPS = [
...
'modelcluster',
'wagtailembedder',
'core',
...
]
For each models registered as a wagtail.wagtailsnippets create an html file to render the template inside a RichText field.
SocialMediaLink
snippet in the core
app, it will look for the following template core/templates/snippets/socialmedialink.html
.snippet
.If no template is defined then an exception will be raised in the frontend when rendering a RichTextField with the embedded snippet in it. Make sure you write some templates for your snippets before start to embedding them.
If the snippet meta has a description field, it will show up next to the snippet name in the admin interface.
from django.db import models
import django.db.models.options as options
options.DEFAULT_NAMES = options.DEFAULT_NAMES + ('description',)
@register_snippet
class MySnippet(models.Model):
# fields definition
class Meta:
description = "My Snippet Description"
setup.py
, following semver.make publish
(confirm, and enter your password).