Django Page Tours#

Django Page Tours gives a Django site guided tours of its pages. You declare a tour for a page in Python, next to the view that renders it, as a short list of steps that each point at one part of the page. Driver.js, shipped inside the package, shows the tour in the visitor’s browser.

A tour plays by itself the first time a browser opens its page and then stays out of the way. A visitor can play it again from a replay control you place. It works from the keyboard and with a screen reader, speaks the page’s language, and takes your site’s look. A project can change the tours of the apps it installs without editing them.

Requirements#

  • Python 3.12 or 3.13

  • Django 5.2, 6.0 or 6.1

Installation#

pip install django-page-tours

Add the app to INSTALLED_APPS:

INSTALLED_APPS = [
    # ...
    "page_tours",
]

Include the package’s stylesheet and scripts once, in the <head> of your base template:

{% load static %}
<head>
  ...
  <link rel="stylesheet" href="{% static 'page_tours/page-tours.css' %}">
  <script src="{% static 'page_tours/vendor/driver.js-1.11.0/driver.js.iife.js' %}" defer></script>
  <script src="{% static 'page_tours/page-tours.js' %}" defer></script>
</head>

On a page with no tour they do nothing.

Installation in the developer guide says what each step sets up.

Example#

Declare a tour and put it in a view’s context:

from django.views.generic import TemplateView

from page_tours import Tour, TourStep

DASHBOARD_TOUR = Tour(
    name="dashboard",
    steps=[
        TourStep(title="Welcome", description="A quick look around."),
        TourStep(title="Projects", description="Your work is here.", element="#projects"),
    ],
)


class DashboardView(TemplateView):
    template_name = "dashboard.html"
    extra_context = {"tour": DASHBOARD_TOUR}

Output it in the page’s template, dashboard.html:

{% extends "base.html" %}
{% block content %}
  <ul id="projects">...</ul>
  {{ tour }}
{% endblock content %}

The page plays the tour when it opens, and the browser remembers it by its name, dashboard. Adding a tour to a page covers naming a tour, function-based views, steps and translation.

Next steps#

About the project#

  • Goals: the standing directions the package works toward.

  • Domain model: what tour, tour step, seen, tour version and replay mean here.

  • Constitution: the rules every change is reviewed against.

  • Changelog: what changed in each release.

Support#

Report a problem on the issue tracker. Everyone taking part follows the code of conduct.

Licence#

MIT. Driver.js is also MIT-licensed.