Install postgresql postgresql-client packages. Then start the postgresql service.
Now run the psql shell as postgres user.
Create an user that you want to use with django. Here I am going
to create database user ragsagar
with password s0mestr0ngPassw0rd
.
Permission to create database is also given to this user
by appending CREATDB
. If this is not given django tests will fail when it
try to create test database while running tests.
Create a database with the created user as its owner. I am going to
create a database with name djangodb
By default postgres will only allow peer authentication for local
users. So we have to open the authentication configuration file
/etc/postgresql/9.1/main/pg_hba.conf
and change the auth method
of local users from peer to md5.
Find the line which looks like following
And change it to
Restart the postgresql service and check if you are able to connect to the database from the shell. It will ask for password and opens a psql shell like shown below.
Open your django project settings.py file and add the database name, user and password.
Make migrations and create tables with it.
Now go make awesome webapps with postgres datastore.
Happy Hacking :-)