简体   繁体   中英

Problems with django app DATABASES setting for heroku deployment

When I change my setting of Database according to the official guide as DATABASES['default'] = dj_database_url.config() It has NameError: name 'DATABASES' is not defined when building.

When I change the syntax of database settings to DATABASES = { 'default': dj_database_url.config() } , it has settings.DATABASES is improperly configured. Please supply the ENGINE value. Check settings documentation for more details. settings.DATABASES is improperly configured. Please supply the ENGINE value. Check settings documentation for more details. when opening the app locally. and it has Internal Server Error: The server encountered an unexpected internal server error (generated by waitress) when launching from heroku.

Notice, this way worked once. But when i merge my code with my friends, it has problem again. I roughly located it was database problem. So i delete the database on heroku and wanted to sync again. But when I sync the database, it has Import error: No module named events .

When I change the setting back to the original way: DATABASES = { 'default': { 'ENGINE': 'django.db.backends.sqlite3', 'NAME': os.path.join(PROJECT_PATH, 'db.sqlite3'), } } It can work locally(of course), but can't in the heroku, with the error of Import error: No module named events too when syncing the database.

PS: 1, I made sure that Heroku installed all the requirements I need to run the app, especially i triple checked all the files: models, views, urls, etc. 2, I use waitress as the server instead of gunicorn recommended by the Heroku official guide.

How can I fix it?

You need a DATABASE_URL environment variable that dj_database_url will read.

To set it, run heroku config: set DATABASE_URL=<your database url> from your terminal.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM