Django Test Error "Permission denied to create database" - Using Heroku Postgres Django Test Error "Permission denied to create database" - Using Heroku Postgres django django

Django Test Error "Permission denied to create database" - Using Heroku Postgres


There's no reason for you to need to create a database with your tests. Instead, change your tests to access the local database, if a DATABASE_URL environment variable is undefined. Here's what I do in Node.js, where I have local test and dev databases, and a Heroku-provided production db:

if (typeof(process.env.DATABASE_URL) !== 'undefined') {  dbUrl = url.parse(process.env.DATABASE_URL);}else if (process.env.NODE_ENV === 'test') {  dbUrl = url.parse('tcp://postgres:postgres@127.0.0.1:5432/test');}else {  dbUrl = url.parse('tcp://postgres:postgres@127.0.0.1:5432/db');}