Last active
December 15, 2019 14:36
-
-
Save Sheikh2Imran/aa7592c0640a8bd1232f02e826829e41 to your computer and use it in GitHub Desktop.
How to setup postgres database in Django
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| -> 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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