Installation#
Django Page Tours is a Django app with no models and no settings you have to set, so installing it takes three steps.
Install the package#
pip install django-page-tours
The package depends only on Django. Driver.js is inside it as a static file, so there is nothing to install from npm and nothing is loaded from a CDN.
Add the app to your project#
Add page_tours to INSTALLED_APPS in your settings:
INSTALLED_APPS = [
# ...
"django.contrib.staticfiles",
"page_tours",
]
Django can now find the package’s static files. There are no migrations to run.
Include the package’s files in your base template#
A tour needs one stylesheet and two scripts, which the package ships as static files. Include
them 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>
To put hints on pages as well, add Driver.js’s hints script after its main one:
<script src="{% static 'page_tours/vendor/driver.js-1.11.0/hints.iife.js' %}" defer></script>
To put a checklist on pages as well, add Driver.js’s checklist script after the hints one:
<script src="{% static 'page_tours/vendor/driver.js-1.11.0/checklist.iife.js' %}" defer></script>
Load Driver.js before
page-tours.js. The package’s script plays the tour with it.deferis optional. The script waits until the page is parsed before it looks for the tour, so the scripts work in the<head>or at the end of the<body>, with or withoutdefer.Link the stylesheet wherever you like. Before a tour plays, the script moves it to the start of the
<head>, so that Driver.js’s styles sit under every style of your own (see Styling tours). The script finds the link by its path,page_tours/page-tours., so a hashed file name fromManifestStaticFilesStorageis found too.On a page with no tour, hints or checklist the files do nothing. Nothing shows, and a replay control, a hints restore control or a checklist toggle control marked
hiddenstays hidden.
The files come from your own static files, so nothing is loaded from another site. Each page
then outputs its own tour with {{ tour }}, the way a form outputs its assets with
{{ form.media }}. Adding a tour to a page shows how.
Settings#
None are required. Three are there when you need them:
PAGE_TOURS_CLASSESgives the parts of a shown step classes of your own. See Styling tours.PAGE_TOURS_OVERRIDESreplaces or turns off the tour of an installed app. See Tours from reusable apps.PAGE_TOURS_TEXTwords the buttons and progress text of every tour, set of hints and checklist at once. See Word every tour on the site.