I’m working on one of my first Django projects. I am deploying to Heroku.
Following the doc titled ‘Concurrency and Database Connections in Django’, I just added the pgbouncer buildpack with: $ heroku buildpacks:add heroku/pgbouncer. The build log includes this:
…
remote: -----> No change in requirements detected, installing from cache
remote: -----> Installing pip 20.1.1, setuptools 47.1.1 and wheel 0.34.2
remote: -----> Installing SQLite3
remote: -----> Installing requirements with pip
remote: -----> pgbouncer app detected
remote: Using pgbouncer version: 1.14.0
…
I’m wondering about the third line there because my Django project is already configured with a PostgreSQL db populated with some data. When I navigate to my web app, the PostreSQL db data is still being served (which is what I actually prefer). So does this mean that the buildpack output about SQLite3 is inaccurate? Was SQLite installed or not?
So the short answer to your question is that, yes, you are loading the sqlite libraries, and you are using PostgreSQL.
Remember that the settings.py file is just Python code. So you’re setting a variable named DATABASES in line 93, and then changing its value at line 123.
I’m guessing you could remove lines 93-97, since you’re going to be defining your DATABASES variable in line 123.
Also, unless something else is going on that you haven’t provided here, line 122 isn’t doing anything for you and likely can be deleted as well.
Thank you, KenWhitesell, for your help and guidance so far.
I need SQLite for testing locally and Postgres for my project deployed on Heroku. So I need both. My next step is to declare both configuration variables in separate settings.py, one settings.py for testing locally and one for production remotely. I have already begun working on that as described in Casey Faist’s tutorial: From Project to Productionized with Python | Heroku
Then my local dev server chokes with this traceback:
ImproperlyConfigured at /
settings.DATABASES is improperly configured. Please supply the ENGINE value. Check settings documentation for more details.
…
Say I reverse the comment, so that the first line is active and the second line is commented out:
Looking at the docs for dj_database_url, it looks like the DATABASES line should be the only one you need. If it’s failing in your local dev environment, then I would assume that it’s because you’re not setting your environment variables correctly.
I’m saying that the referenced documentation is saying that that’s all that is necessary.
I don’t believe I’ve said anything about those two lines - that’s what you’ve reported in your other post as a solution to a different problem.
You have not posted a KeyError message in this thread. I’m going to assume you’re referring to this snippet:
See the referenced docs for dj_database_url for the environment requirement (DATABASE_URL) for using the .config method. Verify that that settings has been made and is correct for your local dev environment.