0

My Django project on Heroku I want to migrate from SQLite to PostgreSQL. I changed my settings.py to PostgreSQL. On Windows I installed PostgreSQL and psycopg2. I created the database manually.

As I run makemigrations it creates an SQLite database. Why?

user4157124
  • 2,809
  • 13
  • 27
  • 42
Dacey
  • 11
  • 6
  • Does this answer your question? [Django: What are the best practices to migrate a project from sqlite to PostgreSQL](https://stackoverflow.com/questions/3476606/django-what-are-the-best-practices-to-migrate-a-project-from-sqlite-to-postgres) – mattm Jan 22 '20 at 19:07

2 Answers2

0

After you have run python manage.py makemigrations you need to run python manage.py migrate to apply the data to the new database.

0

@Dacey you'll need to edit the settings.py file and change the database name (and potentially connection).

Database https://docs.djangoproject.com/en/4.1/ref/settings/#databases

''' here you use triple quotes to block out your original statement
DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': BASE_DIR / 'old_sqlite.db',
    } } 
close your triple quotes    ''' 

Change the above to something like this

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'PostGres_New',
'USER': 'postgres',
'PASSWORD': 'postgres',
'PORT':'5432',
'HOST':'localhost',
    } }
Nick_Jo
  • 101
  • 9