django-embed-video/README.rst

84 lines
1.9 KiB
ReStructuredText
Raw Normal View History

2013-05-31 11:22:44 +00:00
django-embed-video
==================
2015-05-01 08:51:52 +00:00
Django app for easy embedding YouTube and Vimeo videos and music from SoundCloud.
2013-06-26 10:54:56 +00:00
.. image:: https://jazzband.co/static/img/badge.svg
:target: https://jazzband.co/
:alt: Jazzband
2016-09-04 11:30:36 +00:00
.. image:: https://travis-ci.org/jazzband/django-embed-video.png?branch=master
:target: https://travis-ci.org/jazzband/django-embed-video
2013-07-30 21:31:31 +00:00
.. image:: https://coveralls.io/repos/yetty/django-embed-video/badge.png?branch=master
:target: https://coveralls.io/r/yetty/django-embed-video?branch=master
2013-05-31 11:22:44 +00:00
2013-08-22 08:53:31 +00:00
Documentation
*************
2013-06-01 13:01:52 +00:00
2013-08-22 08:55:25 +00:00
Documentation is here: http://django-embed-video.rtfd.org/
2013-06-01 13:38:53 +00:00
2013-06-01 13:21:01 +00:00
2013-08-22 08:53:31 +00:00
Quick start
************
2013-06-01 13:01:52 +00:00
2013-08-22 08:53:31 +00:00
#. Install ``django-embed-video``:
2013-06-01 13:01:52 +00:00
2013-08-22 08:53:31 +00:00
::
2013-06-01 13:01:52 +00:00
2013-08-22 08:53:31 +00:00
pip install django-embed-video
2013-06-01 13:01:52 +00:00
2013-06-01 13:21:01 +00:00
2013-08-22 08:53:31 +00:00
or from sources
2013-06-01 13:01:52 +00:00
2013-08-22 08:53:31 +00:00
::
2013-06-01 13:01:52 +00:00
pip install git+https://github.com/jazzband/django-embed-video
2013-06-01 13:21:01 +00:00
2013-06-01 13:01:52 +00:00
2013-08-22 08:53:31 +00:00
#. Add ``embed_video`` to ``INSTALLED_APPS`` in your Django settings.
2013-06-01 13:21:01 +00:00
2013-12-23 08:50:32 +00:00
#. If you want to detect HTTP/S in template tags, you have to set ``request``
2017-04-20 11:33:28 +00:00
context processor in ``settings.TEMPLATES``:
2013-06-01 13:01:52 +00:00
2013-12-23 08:50:32 +00:00
::
2017-04-20 11:33:28 +00:00
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
# ...
'OPTIONS': {
'context_processors': [
# ...
'django.template.context_processors.request',
],
},
},
]
2013-12-23 08:50:32 +00:00
#. Usage of template tags:
2013-06-01 13:01:52 +00:00
2013-08-22 08:53:31 +00:00
::
2013-06-01 13:01:52 +00:00
2013-08-22 08:53:31 +00:00
{% load embed_video_tags %}
2013-06-01 13:21:01 +00:00
2013-08-22 08:53:31 +00:00
The video tag:
{% video item.video as my_video %}
2013-06-27 08:10:27 +00:00
URL: {{ my_video.url }}
Thumbnail: {{ my_video.thumbnail }}
Backend: {{ my_video.backend }}
2013-12-23 08:50:32 +00:00
2014-01-07 09:05:38 +00:00
{% video my_video "large" %}
2013-08-22 08:53:31 +00:00
{% endvideo %}
2013-06-01 13:01:52 +00:00
2013-08-22 08:53:31 +00:00
Or embed shortcut:
{% video my_video '800x600' %}
2013-06-01 13:01:52 +00:00
2013-12-23 08:50:32 +00:00
#. Usage of model fields
2013-08-22 08:53:31 +00:00
::
2013-08-22 08:53:31 +00:00
from django.db import models
from embed_video.fields import EmbedVideoField
2013-06-01 13:01:52 +00:00
2013-08-22 08:53:31 +00:00
class Item(models.Model):
video = EmbedVideoField() # same like models.URLField()