How to use dj-database-url while connecting with postgresql in heroku using python

前端 未结 2 1419
不思量自难忘°
不思量自难忘° 2021-02-04 21:23

I\'m here because I\'m really really new with heroku-python-django-postgresql group. I have googled for a usage for dj-database-url and I don\'t understand why i have to use it

2条回答
  •  灰色年华
    2021-02-04 22:17

    dj-database-url is a utility to help you load your database into your dictionary from the DATABASE_URL environment variable. Heroku uses environment variables for your database and other addons. To begin using your database you'd simply use the below command to setup your DATABASES dictionary:

    import dj_database_url
    DATABASES['default'] = dj_database_url.config()
    

    And maybe stash DATABASE_URL in your virtualenv activate script.

提交回复
热议问题