The password from settings.py is written in a temporary .pgpass file file whose name is given to psql using the PGPASSFILE environment variable.