Skip to content

Instantly share code, notes, and snippets.

@Sheikh2Imran
Last active December 15, 2019 14:36
Show Gist options
  • Select an option

  • Save Sheikh2Imran/aa7592c0640a8bd1232f02e826829e41 to your computer and use it in GitHub Desktop.

Select an option

Save Sheikh2Imran/aa7592c0640a8bd1232f02e826829e41 to your computer and use it in GitHub Desktop.
How to setup postgres database in Django
-> sudo su - postgres # To perform administrative tasks
-> password # Enter user password
-> psql # Log into a Postgres session
-> CREATE DATABASE db_name;
-> CREATE USER db_user WITH PASSWORD 'your_password';
-> ALTER ROLE db_user SET client_encoding TO 'utf8';
-> ALTER ROLE db_user SET default_transaction_isolation TO 'read committed';
-> ALTER ROLE db_user SET timezone TO 'UTC';
-> GRANT ALL PRIVILEGES ON DATABASE db_name TO db_user;
-> \q # Exit the SQL prompt to get back to the postgres
-> exit # Exit out of the postgres
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'db_name',
'USER': 'db_user',
'PASSWORD': 'your_password',
'HOST': 'localhost',
'PORT': '',
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment