Django app for easy embedding YouTube and Vimeo videos and music from SoundCloud.
Documentation is here: http://django-embed-video.rtfd.org/
Install
django-embed-video:pip install django-embed-video
or from sources
pip install git+https://github.com/jazzband/django-embed-video
Add
embed_videotoINSTALLED_APPSin your Django settings.If you want to detect HTTP/S in template tags, you have to set
requestcontext processor insettings.TEMPLATES:
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
# ...
'OPTIONS': {
'context_processors': [
# ...
'django.template.context_processors.request',
],
},
},
]- Usage of template tags:
{% load embed_video_tags %}
The video tag:
{% video item.video as my_video %}
URL: {{ my_video.url }}
Thumbnail: {{ my_video.thumbnail }}
Backend: {{ my_video.backend }}
{% video my_video "large" %}
{% endvideo %}
Or embed shortcut:
{% video my_video '800x600' %}- Usage of model fields
from django.db import models
from embed_video.fields import EmbedVideoField
class Item(models.Model):
video = EmbedVideoField() # same like models.URLField()