0

How to setup PostgreSQL Database in Django, this night I wanna share simple tutorial how to setup PostgreSQL Database in Django. This problem has been asked and solved with user from http://stackoverflow.com/a/5421511

Installation

Download http://initd.org/psycopg/, then install it under django & python PATH.

After downloading, easily extract the tarball and:

$ python setup.py install

Or if you wish, at [command-line|console] install it by either easy_install or pip. (I prefer to use pip over easy_install for no reason.)

$ easy_install psycopg2

Or this:

$ pip install psycopg2

Configuration

in your settings.py, change default database sqlite3 to this configuration.

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql_psycopg2',
        'NAME': 'db_name',                      
        'USER': 'db_user',
        'PASSWORD': 'db_user_password',
        'HOST': '',
        'PORT': 'db_port_number',
    }
}

Hopefully can help..

database python django

Your Answer

blog comments powered by Disqus