Simple app that works similar to wagtailimages
, but for embedding YouTube and Vimeo videos and music from SoundCloud.
The current version is tested for compatiblily with the following:
- Wagtail versions 2.7 to 2.15
- Django versions 2.2 to 3.2
- Python versions 3.6 and 3.9
Maintained by Basil Shubin, and some great contributors.
First install the module, preferably in a virtual environment. It can be installed from PyPI:
pip install wagtail-embedvideos
You must have django-embed-video installed and configured, see the django-embed-video documentation for details and setup instructions.
Make sure the project is configured for django-embed-video.
Then add the following settings:
INSTALLED_APPS += (
"wagtail_embed_videos",
)
Then run ./manage.py migrate
to create the required database tables.
In models, implement as a ForeignKey
relation, same as wagtailimages
.
# models.py
from wagtail.core.models import Page, PageBase
from wagtail_embed_videos import get_embed_video_model_string
from wagtail_embed_videos.edit_handlers import EmbedVideoChooserPanel
class CustomPage(Page):
video = models.ForeignKey(
get_embed_video_model_string(),
null=True, blank=True,
on_delete=models.SET_NULL,
related_name='+'
)
# ...
content_panels = [
EmbedVideoChooserPanel('video'),
]
In templates, load the embed_video_tags
library in every template where you want to use it:
<!-- custom_page.html -->
{% load embed_video_tags %}
{% video self.video.url as my_video %}
{% video my_video 'small' %}
{% endvideo %}
Check django-embed-video documentation for more details.
If you like this module, forked it, or would like to improve it, please let us know! Pull requests are welcome too. :-)
wagtail-embedvideos was originally started by InfoPortugal, S.A. who has now unfortunately abandoned the project.
wagtail-embedvideos
is released under the BSD license.