Skip to content

Django app to search or join a database of underrepresented experts. This version is geared to science, health and environment sources and journalists.


Notifications You must be signed in to change notification settings


Repository files navigation

This is an open-source tool for creating a database of sources.

(hat tip to Digital Ocean Django and Postgres)

The following instructions are intended for Ubuntu 16.

Prep the system

sudo apt-get update
sudo apt-get install python3-pip
sudo apt-get install git
sudo apt-get install python3-pip python3-dev libpq-dev postgresql postgresql-contrib nginx

Install virtualenvwrapper

Install packages

sudo -H pip3 install --upgrade pip
sudo -H pip3 install virtualenv virtualenvwrapper

For Python3 and pip3

echo "export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python3" >> ~/.bashrc

Finalize the process

echo "export WORKON_HOME=~/Env" >> ~/.bashrc
echo "source /usr/local/bin/" >> ~/.bashrc

Execute the bash script

source ~/.bashrc

Set up the database

Enter the database shell

sudo -u postgres psql

Create the database


Create the user

CREATE USER sourcelistuser WITH PASSWORD 'password-here';

Grant permissions

GRANT ALL PRIVILEGES ON DATABASE sourcelist TO sourcelistuser;

Close the shell


Set up GitHub

Generate ssh key

ssh-keygen -t rsa -b 4096 -C "youremail"

Set up the project

Make the virtual environment

mkvirtualenv sourcelist

Clone the repo (or your fork)

git clone

Change into the directory

cd sourcelist

Install the requirements

pip3 install -r requirements.txt

Create the private settings file and fill in the vars with "UPDATE" comments

mv sourcelist/ sourcelist/

Initial migration for admin tables

python3 migrate

Initial migration for the app

python3 makemigrations sources
python3 migrate

Create a super user

python3 createsuperuser

Collect static assets

python3 collectstatic

Update the firewall permissions

sudo ufw allow 8080

Test the local server

python3 runserver

Then navigate to the live site

Stop the local server

Ctrl + C

Set up uWSGI application server

Exit your virtualenv


Install key pieces

sudo -H pip3 install uwsgi

Make directory for sites

sudo mkdir -p /etc/uwsgi/sites

Make the ini file

sudo vim /etc/uwsgi/sites/sourcelist.ini

Paste in these settings


logto = /var/log/uwsgi/error.log

project = sourcelist
uid = ubuntu
base = /home/%(uid)

chdir = %(base)/%(project)
home = %(base)/Env/%(project)
module = %(project).wsgi:application

master = true
processes = 5

socket = /run/uwsgi/%(project).sock
chown-socket = %(uid):www-data
chmod-socket = 660
vacuum = true

Create a systemd unit file

sudo vim /etc/systemd/system/uwsgi.service

Paste this

Description=uWSGI Emperor service

ExecStartPre=/bin/bash -c 'mkdir -p /run/uwsgi; chown ubuntu:www-data /run/uwsgi'
ExecStart=/usr/local/bin/uwsgi --emperor /etc/uwsgi/sites


Set up nginx reverse proxy cache

Install nginx

sudo apt-get install nginx

Create a config file

sudo vim /etc/nginx/sites-available/sourcelist

Add this

server {
    listen 80;
    server_name YOUR-DOMAIN.COM;
    access_log /var/log/nginx/sourcelist_access.log;
    error_log /var/log/nginx/sourcelist_error.log;

    location = /favicon.ico { access_log off; log_not_found off; }

    location /static/ {
        root /home/ubuntu/sourcelist/;

    location / {
        include         uwsgi_params;
        uwsgi_pass      unix:/run/uwsgi/sourcelist.sock;

Remove the symlink for the default site

sudo rm /etc/nginx/sites-enabled/default

Symlink the available site to an enable site

sudo ln -s /etc/nginx/sites-available/sourcelist /etc/nginx/sites-enabled

Check the configuration

sudo nginx -t

Server final prep

Restart nginx

sudo systemctl restart nginx

Start uwsgi

sudo systemctl start uwsgi

Update the firewall rules

sudo ufw delete allow 8080
sudo ufw allow 'Nginx Full'

Enable uwsgi and nginx to run on startup

sudo systemctl enable nginx
sudo systemctl enable uwsgi

Let's Encrypt CertBot

For example:


Run this command to generate or re-generate the translation file:

python3 makemessages -l es

Run this command to compile the translation:

python3 compilemessages

Deploy steps

TODO: Write a fabric script to do this.

In the virtualenv:

  1. git checkout main

  2. git pull origin main

  3. pip3 install -r requirements.txt

  4. python3 makemigrations

  5. python3 migrate

  6. python3 buildwatson

  7. sudo systemctl restart uwsgi


Django app to search or join a database of underrepresented experts. This version is geared to science, health and environment sources and journalists.







No releases published