How I setup Postgresql with Django 1.11 in Ubuntu 16.04 LTS

Carlos Sisnett
Chingu
Published in
2 min readSep 15, 2017
image: nemesisdesign.net

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:

  1. install postgresql
  2. access postgresql
  3. create a user and a database
  4. add a password to your user
  5. 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:

--

--

Carlos Sisnett
Chingu
Writer for

I’m studying Computer Science and programming online