PostgreSQL with Django


In debian, install the following packages: libpq-dev, postresql-9.3, postgresql-contrib-9.3

Change to postgres user using sudo su - postgres

Create a database using createdb mydb

Create a new user by createuser -P myuser

Open postgresql by psql and grant all on mydb to myuser

Change the database options of the django project by

{.sourceCode .python} DATABASES = { 'default': { 'ENGINE': 'django.db.backends.postgresql_psycopg2', 'NAME': 'mydb', 'USER': 'myuser', 'PASSWORD': 'thepassword', 'HOST': 'localhost', 'PORT': '' }}

Now you can run syncdb in your django configuration to generate the models in Postgres.

Comments !