How I setup Postgresql with Django 1.11 in Ubuntu 16.04 LTS
So naturally the first thing I did was google for a solution, but I had a few hiccups along the way.
The link I found was useful but considering it was written with a different version of django in mind I had to do some steps differently.
The steps I took to setup django and postgresql were:
- install postgresql
- access postgresql
- create a user and a database
- add a password to your user
- use the resource below to change the settings and migrate the new database in django
Of course if you have already installed postgresql you can skip that step.
Installing postgresql
in ubuntu is fairly easy just type on the terminal:
$ sudo apt-get update
$ sudo apt-get install postgresql postgresql-contrib
Accessing postgresql
Type in the terminal the following:
$ sudo -i -u postgres
[Enter your password]:
$ password here
$ psql
psql (9.5.8)
Create a user and a database
now type the following (after the #) and remember the semicolon.
postgres# CREATE USER user_name;
#CREATE DATABASE database_name OWNER user_name;
Add a password to your user
postgres=# ALTER USER user_name WITH PASSWORD ‘password_here’;
Change the default settings in Django to yours
Now you can use this link I found to connect Django to the database, starting from “Updating Settings”:
The sources that helped me get around errors: