Installation

Note

These instructions presume that you have prior knowledge of virtual environments and the Django web framework. For a more comprehensive guide, refer to create your first django-cast site. If you want to incorporate django-cast into an existing Django project, consult the guide on integrating django-cast into a Django Project.

Install the package with pip in a virtual environment:

python -m pip install django-cast

If you don’t already have a Django project, you might want to create one with the following django-admin command:

django-admin startproject mysite

Add following third party apps to your INSTALLED_APPS setting:

INSTALLED_APPS = (
    ...
    "django.contrib.sites",
    "cast.apps.CastConfig",
    "crispy_forms",
    "crispy_bootstrap4",
    "django_filters",
    "django_htmx",
    "rest_framework",
    "fluent_comments",
    "threadedcomments",
    "django_comments",
    "wagtail.api.v2",
    "wagtail.contrib.forms",
    "wagtail.contrib.redirects",
    "wagtail.contrib.settings",
    "wagtail.embeds",
    "wagtail.sites",
    "wagtail.users",
    "wagtail.snippets",
    "wagtail.documents",
    "wagtail.images",
    "wagtail.search",
    "wagtail.admin",
    "wagtail",
    "modelcluster",
    "taggit",
 )

Add some middleware to your MIDDLEWARE_CLASSES setting:

MIDDLEWARE = (
    ...
    "django_htmx.middleware.HtmxMiddleware",
    "wagtail.contrib.redirects.middleware.RedirectMiddleware",
)

Append some required configuration settings to your settings.py:

...
COMMENTS_APP = "fluent_comments"
MEDIA_ROOT = BASE_DIR / "media"
MEDIA_URL = "/media/"

Modify your url-config to include the urls for django-cast and Wagtail:

from django.conf import settings
from django.urls import path, include

from cast import cast_and_wagtail_urls

urlpatterns = [
    ...
    path("", include(cast_and_wagtail_urls)),
]

if settings.DEBUG:
    from django.conf.urls.static import static
    from django.contrib.staticfiles.urls import staticfiles_urlpatterns

    # Serve static and media files from development server
    urlpatterns += staticfiles_urlpatterns()
    urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)

Now run the following commands to create the database tables and a superuser:

python manage.py migrate
python manage.py createsuperuser

Run the development server and visit http://localhost:8000:

python manage.py runserver

To be able to extract posters from videos or get the duration of an audio file you need to install ffmpeg.