ruk·si

Django Tutorial
Setup Database

Updated at 2018-11-23 16:20

Use PostgreSQL as your backend:

echo -e "psycopg2" >> requirements.in
pip-compile --output-file requirements.txt requirements.in
pip install -r requirements.txt

# or if it fails on Mac OS X because of homebrew and openssl
env LDFLAGS="-I/usr/local/opt/openssl/include -L/usr/local/opt/openssl/lib" pip install -r requirements.txt

Edit djangor/settings.py:

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql',
        'NAME': 'djangor',
        'USER': 'djangor',
        'PASSWORD': '',
        'HOST': 'localhost',
        'PORT': '',
    }
}
# in reality, some of this stuff should be read from env variables

Create database and try that it works:

createuser djangor -d # we need privileges to create db for tests
createdb -O djangor djangor
python manage.py migrate
python manage.py runserver