Skip to content

Django for Behavioural Science

Andy Woods speaking to an audience at the Django London meetup in May 2026

Parts of this tutorial and accompanying manuscript were presented under the title Django in the Lab: from live VR studies to WhatsApp diary studies and AI skill tracking, at the Django London meetup on 7 May 2026. Image: Django London.

Plan for 3 to 4 hours for the core chapters.

This tutorial is the hands-on companion to the paper First Steps in Django Web Development: Applied Examples from Behavioural Research (Woods, currently under peer review). The paper explores why a behavioural scientist might want to build their own web application, with examples drawn from real studies. Here, though, is where you actually build one.

You've built an experiment in jsPsych. It runs great in the browser, but how do you store your results? When your participant closes the tab, their results vanish! This is the job of the backend, and this guide shows you how to build such a backend with Django. Think Pavlovia or Gorilla, but utterly bespoke, so you can add just about any feature you can imagine to make your study more powerful. In one of my own studies that meant wiring in a Raspberry Pi and a webcam, to estimate how many people were milling about a room at key moments.

Other Django tutorials

These are great. You should check them out too!

What you'll build

Here we will be building a small study-hosting platform. A researcher adds a study by pasting in their jsPsych timeline. The platform adds data-capture, serves the study to participants (recruited from Prolific if you want that), and stores study data in a database that you can then browse and export.



A Flanker task, shown here as a static preview generated from the Django template. The app you build will serve it through Django. Click inside the box, then press any key to start. On each trial, press f if the centre arrow points left and j if it points right. It needs a keyboard, and nothing is saved. Restart · Open in a new tab

A few things to point out

  • You can hide the comments in code blocks by clicking above the code block or in the menu bar
  • Code blocks have a copy button, top-right corner
  • Most blocks have a "… on GitHub" link underneath which takes you to the file on GitHub
  • Some terms here have a dotted underline. Hover over, or tap, the term, for a brief explanation (e.g. slug)
  • If you spot a mistake, please let me know! Click the GitHub link in the menu bar, then click 'Issues' in GitHub's own menu. Thanks!