Install django and dj-database-url for local development

Here in the comments to the answer, someone asked these questions. But the answer is still unclear to me.

I run my django site in Herouku, and the dj-database-url module is required to work with Postgresql. How to start django with DATABASES = dj-database-url () in settings.py on my local computer? Changing the code before clicking on Heroku is pretty ugly.

+4
source share
1 answer

There are many ways to manage different development / development environments.

One of them is to have a local settings file, which is imported at the bottom of your settings file, which is not in version control, and therefore not in the hero.

Another is any way to distinguish a heroku environment from your local environment. For example, an arbitrary environment variable.

Another, the default argument is passed to dj_database_url , which basically does this simple if for you.

 import dj_database_url DATABASES['default'] = dj_database_url.config( default='sqlite:////path-to-my/database.sqlite') 

Remember that this settings file is just python. For example, you could use one database on Tuesday, for example, any action you can think of will work.

+11
source

All Articles