Q:

Django with Postgresql on Heroku - settings.DATABASES is improperly configured. Please supply the NAME value

I deployed on Heroku my project in Docker with Angular 4 frontend, Django backend and Postgresql database. At this moment my files look as shown below. When I open app I get error:
2017-07-11T19:51:14.485577+00:00 app[web.1]:     self.connect()
2017-07-11T19:51:14.485577+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.6/site-packages/django/db/utils.py", line 94, in __exit__
2017-07-11T19:51:14.485578+00:00 app[web.1]:     six.reraise(dj_exc_type, dj_exc_value, traceback)
2017-07-11T19:51:14.485578+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.6/site-packages/django/utils/six.py", line 685, in reraise
2017-07-11T19:51:14.485578+00:00 app[web.1]:     raise value.with_traceback(tb)
2017-07-11T19:51:14.485579+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.6/site-packages/django/db/backends/base/base.py", line 213, in ensure_connection
2017-07-11T19:51:14.485579+00:00 app[web.1]:     self.connect()
2017-07-11T19:51:14.485579+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.6/site-packages/django/db/backends/base/base.py", line 189, in connect
2017-07-11T19:51:14.485580+00:00 app[web.1]:     self.connection = self.get_new_connection(conn_params)
2017-07-11T19:51:14.485580+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.6/site-packages/django/db/backends/postgresql/base.py", line 176, in get_new_connection
2017-07-11T19:51:14.485580+00:00 app[web.1]:     connection = Database.connect(**conn_params)
2017-07-11T19:51:14.485581+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.6/site-packages/psycopg2/__init__.py", line 130, in connect
2017-07-11T19:51:14.485581+00:00 app[web.1]:     conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
2017-07-11T19:51:14.485582+00:00 app[web.1]: django.db.utils.OperationalError: could not translate host name "db" to address: Name or service not known

Locally everything seems to be working properly. I use docker exec -ti name /bin/bash then python {path}\manage.py migrate and database is added. 
Maybe there is a problem with my database migration on Heroku?
Procfile:
web: sh -c 'cd PROJECT/backend/project && gunicorn project.wsgi --log-file -'

Project tree:
DockerProject
      ├── Dockerfile
      ├── Procfile
      ├── init.sql
      ├── requirements.txt
      ├── docker-compose.yml
      └── PROJECT
            ├── frontend
                   └── all files
            └── backend
                  └── project
                        ├── prices
                        ├── manage.py
                        └── project
                              └── all backend files

Frontend's Dockerfile:
# Create image based on the official Node 6 image from dockerhub
FROM node:6

# Create a directory where our app will be placed
RUN mkdir -p /usr/src/app

# Change directory so that our commands run inside this new directory
WORKDIR /usr/src/app

# Copy dependency definitions
COPY package.json /usr/src/app

# Install dependecies
RUN npm install

# Get all the code needed to run the app
COPY . /usr/src/app

# Expose the port the app runs in
EXPOSE 4200

# Serve the app
CMD ["npm", "start"]

Main directory's Dockerfile:
FROM python:3.6.1
ENV PYTHONUNBUFFERED 1
RUN mkdir /code
WORKDIR /code
ADD requirements.txt /code/
RUN pip3 install -r requirements.txt
ADD . /code/

docker-compose.yml:
version: '3'

services:
  db:
    image: postgres
    environment:
      POSTGRES_USER: aso
      POSTGRES_PASSWORD: somepass
  django:
    build: .
    command: python3 MainDirectory/backend/myProject/manage.py runserver 0.0.0.0:8001
    volumes:
      - .:/code
    ports:
      - "8001:8001"
    depends_on:
      - db
  angular:
    build: MainDirectory/frontend
    ports:
      - "4200:4200"
    depends_on:
      - django

init.sql:
CREATE USER myUser;
CREATE DATABASE myProject;
GRANT ALL PRIVILEGES ON DATABASE myProject TO myUser;

UPDATE
My project including postgresql database was working properly with this setting. However as I have mentioned there was a problem with Heroku.
DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql',
        'NAME': 'aso',
        'USER': 'postgres',
        'HOST': 'db',
        'PORT': 5432,
    }
}

Based on this topic I changed my database settings to
DATABASES = {'default': dj_database_url.config(default='postgres://localhost')}

Unfortunately, I get:
ImproperlyConfigured at /
settings.DATABASES is improperly configured. Please supply the NAME value.

Any suggestions?

A:

I want to help you and I give you here what you could change to make it wok but I cannot promise anything. I know you are now trying quite a long time to make that app run. 

Make it run local 

Change the DATABASES to the following: 
DATABASES = {
 "default": 
 {
  "ENGINE": "django.db.backends.postgresql_psycopg2", #one of those should work
  'ENGINE': 'django.db.backends.postgresql',   #one of those should work
  "NAME": 'myProject',
  "HOST": "localhost", 
  "PORT": "5432",
 }
 }

Of course only choose one Engine and comment the other one out. 
You can also try to access your DB over a desktop application like PSequel there you can login to your db with the given parameters. 

Directly take the Heroku DB

Heroku provides a DB when you initialize a Project. You should have a Postgres Add-on. go to that link "https://dashboard.heroku.com/apps/YourAppName/settings" (the settings page ob your app on Heroku.com) and there you got the point "Config Variables" click on the button next to it. There should pop out a field with DATABASE_URL copy the link next to it with the format postgres://fasdfsdafsadfdsafsdafsda:123123132132123asdfdsafdssafdsfdaasdfsadf2-321-21-312-321.casdte-1.amazonaws.com:5432/adsdasdasads123
NOTE! Never give that link to anybody!
now you can use in your settings.py
  import dj_database_url 
  DATABASES = {'default': dj_database_url.parse('postgres://the-just-copied-link-comes-here

With that in your settings.py you have the Heroku DB in the Project. Its very slow for development but you need to send it do it this way when you push the code to Heroku. Don't forget to install dj_database_url if don't have it. Package
I hope that brings you a step closer to your goal. 
in settings.py 
EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
MAILER_LIST = ['yourMail@gmail.com']
EMAIL_HOST = ' smtp.gmail.com'
EMAIL_HOST_USER = 'Name'
EMAIL_HOST_PASSWORD = 'lalalala'
EMAIL_PORT = 587
EMAIL_USE_TLS = True
DEFAULT_FROM_EMAIL = 'root@localhost'
ADMINS = [("Name", 'Mail@gmail.com')]
LOGGING = {
     'version': 1,
     'disable_existing_loggers': False,
     'handlers': {
         'mail_admins': {
             'level': 'ERROR',
             'class': 'django.utils.log.AdminEmailHandler' }},
     'loggers': {'django.request': {
             'handlers': ['mail_admins'],
             'level': 'ERROR',
             'propagate': True, },}}

You also don't have to do that now but with this you can see the errors you are getting on heroku in the logging section. There you have the traceback and can figure out why your fronted isn't working ( right now im guessing its a 404 with some static files). Tell me when you wrote your next question ;)  Get to logs from your heroku app https://dashboard.heroku.com/apps/YourAppName/logs

