1

I changed the database from SQLite3 to PostgreSQL in my Django project. Is it possible to store my new database in the GitHub repository so that after cloning and running by the command

python manage.py runserver

the project has started with the whole database?

2
  • 2
    No, that's not possible and also not advisable for SQlite. But Django offers fixtures to initialize the database. Commented Apr 25, 2020 at 13:30
  • 1
    If you want to be able to recreate your postgres db, look at pg_dump and pg_restore. You can check the output of the former into your repo if you should so desire. Commented Apr 25, 2020 at 13:33

1 Answer 1

1

You cannot save the database as such, you can instead create fixtures to be run. Whenever someone will clone the project, he/she can simple run those fixtures to populate the database.

Sign up to request clarification or add additional context in comments.

3 Comments

Any advice / source on how to create such fixtures ? Will I have to change the settings in DATABASES in settings.py then?
No, database settings etc. need not be changed. You can follow one of these links to do that: docs.djangoproject.com/en/3.0/howto/initial-data

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.