3

I already changed the settings.py:

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql_psycopg2',
        'NAME': 'examdatabase',
        'USER': 'examdatabaseuser',
        'PASSWORD': '11111',
        'HOST': '127.0.0.1',
        'PORT': '5432',
    }
}

I also installed PostgreSQL, and created a database:

sudo apt-get install python-psycopg2
sudo apt-get install postgresql

sudo su - postgres 
createuser --superuser examdatabaseuser
psql
\password examdatabaseuser
createdb examdatabase

I deleted the sqlite database file in my project, but when I run the command python manage.py runserver it still uses sqlite. Why?

Related info: I use virtualenv (/home/py3env). Ubuntu Server 14.04 LTS.

TJB
  • 3,706
  • 9
  • 51
  • 102
xiang
  • 393
  • 3
  • 14
  • The config is correct. Check that the variable is not getting redefined anywhere later and there is no another settings module in a directory from `sys.path` before your project dir. – Igonato Mar 29 '15 at 12:44
  • @Igonato I added a print('ahahah') in settings.py and when runserver or uwsgi, it does print. – xiang Mar 29 '15 at 13:38
  • @xiang did you ever figure this out? I'm having the same issue at http://stackoverflow.com/questions/30180181/how-do-i-switch-from-sqlite-to-postgres-in-django – YPCrumble May 12 '15 at 02:01

0 Answers0