Hi David, Thanks for the feedback!
I'm checking out dj_database_url and have a few follow up questions I was hoping you (or someone) could help me with. 1. Since this app is dockerized, I have my existing env vars in my docker-compose-prod.yml file. Is that where I should list DATABASE_URL? Like: *db: image: postgres:11 volumes: - postgres_data:/var/lib/postgresql/data/environment:- DATABASE_URL=postgresql://<username>:<password>@<host>:<port>/<databasename> - *2. Does the below formatting look correct to you from my settings.py? I am running into issues with the env var DATABASE_URL and getting this error: Environment variable "{}" not set' *DATABASES = { 'default': dj_database_url.config(env("DATABASE_URL"), default="postgres://postgres@db/postgres", conn_max_age=1800), 'ENGINE': 'django.db.backends.postgresql',}* 3. I am also getting this error when running locally. Do you have any advice for troubleshooting? web_1 | [2020-11-03 16:35:59 +0000] [7] [ERROR] Error handling request /NDCs/ web_1 | Traceback (most recent call last): web_1 | File "/usr/local/lib/python3.8/site-packages/gunicorn/workers/sync.py", line 134, in handle web_1 | self.handle_request(listener, req, client, addr) web_1 | File "/usr/local/lib/python3.8/site-packages/gunicorn/workers/sync.py", line 175, in handle_request web_1 | respiter = self.wsgi(environ, resp.start_response) web_1 | File "/usr/local/lib/python3.8/site-packages/django/core/handlers/wsgi.py", line 131, in __call__ web_1 | signals.request_started.send(sender=self.__class__, environ=environ) web_1 | File "/usr/local/lib/python3.8/site-packages/django/dispatch/dispatcher.py", line 177, in send web_1 | return [ web_1 | File "/usr/local/lib/python3.8/site-packages/django/dispatch/dispatcher.py", line 178, in <listcomp> web_1 | (receiver, receiver(signal=self, sender=sender, **named)) web_1 | File "/usr/local/lib/python3.8/site-packages/django/db/__init__.py", line 46, in reset_queries web_1 | for conn in connections.all(): web_1 | File "/usr/local/lib/python3.8/site-packages/django/db/utils.py", line 229, in all web_1 | return [self[alias] for alias in self] web_1 | File "/usr/local/lib/python3.8/site-packages/django/db/utils.py", line 229, in <listcomp> web_1 | return [self[alias] for alias in self] web_1 | File "/usr/local/lib/python3.8/site-packages/django/db/utils.py", line 211, in __getitem__ web_1 | self.ensure_defaults(alias) web_1 | File "/usr/local/lib/python3.8/site-packages/django/db/utils.py", line 176, in ensure_defaults web_1 | conn.setdefault('ATOMIC_REQUESTS', False) web_1 | AttributeError: 'str' object has no attribute 'setdefault' Many thanks in advance for any insights. Best, Marc On Sat, Oct 31, 2020 at 11:45 PM David Nugent <dav...@uniquode.io> wrote: > It's been a while since I used heroku, but iirc it just uses a formatted > pg url. > > Install the module dj-database-url and use this in settings instead of the > default DATABASES layout, something like: > > > DATABASES = { > 'default': > dj_database_url.config(os.environ['DATABASE_URL'], conn_max_age=1800) > } > > > Then set DATABASE_URL in the heroku (and your development) environment. > This setting will be of the form: > > DATABASE_URL=postgresql://<username>:<password>@<host>:<port>/<databasename> > > > Again, its been a while but I also seem to recall that the DATABASE_URL is > provided to your app automagically(?) a part of the provisioning so does > not need to be explicitly set there. Using the dj_database_url module in > your settings above is the key. > > > > -- M: +1-646-541-2108 W: marcjohnson.info <https://www.marcjohnson.info/> -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CACH3BCQi2f7uybMPb%3DXXmLuczNwX3%2Bi-enyS-4Lmk_%2Ba7etYbw%40mail.gmail.com.