0

Oh my local test for Django I am attempting to switch my default local database from an old SQLLite database to a Postgres database to mimic my live environment hosted through heroku. To do this I have the postgres database locally and I changed all my settings.py as shown below, but Django does not recognize that the DB exists. In addition to this, if I run migrate or syncdb it still tries to recreate the old sqllite3 database. Anybody have any experience with this change from one database to another and see any similar problems?

DATABASES = {

    'default': {
        'ENGINE': 'django.db.backends.postgresql_psycopg2', # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.
        'NAME': 'postgres',                      
    # Or path to database file if using sqlite3.
        # The following settings are not used with sqlite3:
        'USER': 'myusername',
        'PASSWORD': 'mypassword',
        'HOST': 'localhost',                      # Empty for localhost through domain sockets or '127.0.0.1' for localhost through TCP.
        'PORT': '5432',                      # Set to empty string for default.
    }
}
1
  • Thank you for the edit. Still learning the formatting.
    – mparrish
    Jan 30, 2014 at 21:34

1 Answer 1

0

You are probably using a wrong settings file, or have something like local_settings.py that overrides your settings, or have duplicate DATABASES entries in your settings. Execute:

python manage.py diffsettings

Do you see the correct DATABASES settings there?

7
  • I did not, but I'm not sure where that could be coming from as I don't have another settings file. Could it have anything to do with git branching causing the problem?
    – mparrish
    Jan 30, 2014 at 23:30
  • Something is not right in your configuration. In your manage.py, DJANGO_SETTINGS_MODULE should include the module name of your settings.py, for example myproj.settings.
    – Udi
    Jan 30, 2014 at 23:35
  • Its correctly listed under the DJANGO_SETTINGS_MODULE. I'm completely stumped why it might be hanging on to the old settings.
    – mparrish
    Jan 30, 2014 at 23:37
  • delete all your .pyc files. They are cached compiled versions of your .py files.
    – Udi
    Jan 30, 2014 at 23:48
  • Just tried that and unfortunately they seem to recreate themselves immediatly afterwards and it does not solve the problem. I have a feeling I'm doing something really stupid here...
    – mparrish
    Jan 31, 2014 at 0:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.