Opal Management Commands

Opal ships with a number of Django management commands which can be invoked with python manage.py command.


Creates patients with randomised data.


python manage.py create_random_data --number 3000


Creates any subrecord singletons which are missing. This is useful when creating a new singleton subrecord to backfill existing patients or episodes.

Will not create anything if singletons exist, so safe to be run as part of e.g. a deployment script.

python manage.py create_singletons


Deletes all instances of lookuplist and synonym entries.

python manage.py delete_all_lookuplists


Examines patients in the system and looks for possible duplicates. Prints a report of patients with matching names, dates of birth or hospital numbers.

python manage.py detect_duplicates



Prints current lookuplist and synonym values as JSON to stdout. Suitable to be used as the input to load_lookup_lists

python manage.py dump_lookup_lists


Load lookuplists and synonym values.


By default this command will look in ./yourapp/data/lookuplists.json as well as in ./yourapp/data/ for any files with a name matching the API name of a lookuplist (e.g. ./yourapp/data/conditions.json)

python manage.py load_lookup_lists

serve <addrport>

Run the development server.

By default this will start a web server on localhost:8000. Users may specify either a port or an addr port pair to change this.

opal serve # server on localhost:8000
opal serve 7798 # server on localhost:7798
opal serve # server on

scaffold <appname>

Use with new record models.

Creates and runs automatic migrations, creates display and form (modal) templates.

Running with --dry-run will run makemigrations with --dry-run and print display and form templates that would be generated.