0

I have a Django application that is successfully being hosted on a remote server using Nginx. The production DB is PostgreSQL.

I have a development server where I'd like to change the code for the Django application. When I use python manage.py runserver for testing, I'd ideally prefer to avoid touching the production DB at all.

This is my first time crossing this bridge. Can someone shed some light on the best practice for 'stubbing' the entire database for development? Can you do some if/else statement in settings.py to use SQLite? Or is there a better solution?

Scott Skiles
  • 3,647
  • 6
  • 40
  • 64

1 Answers1

1

You can definitely use if/else statements in settings.py, or any Python code really.

Common practice is to put values which differ, especially secrets like database passwords, in environment variables. You set these to different values in production or locally and access them in Python using os.environ.

Alex Hall
  • 34,833
  • 5
  • 57
  • 89