title: Django docker - could not translate host name "db" to address: nodename nor servname provided, or not known
body: <p>I'm relatively new to Django and Docker and am following a tutorial to build a mini application. However, I'm getting stuck with the following error:</p>
  
  <p><code>django.db.utils.OperationalError: could not translate host name "db" to address: nodename nor servname provided, or not known</code></p>
  
  <p>My docker-compose file looks as follows:</p>
  
  <pre><code> version: '3'
   services:
    db:
       image: 'postgres'
       ports:
         - '5432'
    core:
      build:
        context: .
        dockerfile: Dockerfile
      command: python3 manage.py runserver 0.0.0.0:8000
      ports:
        - '8000:8000'
      volumes:
        - .:/code
      depends_on:
        - db
      links:
        - db:db
  </code></pre>
  
  <p>My settings.py file contains the database:</p>
  
  <pre><code>DATABASES = {
  'default': {
      'ENGINE': 'django.db.backends.postgresql',
      'NAME': 'postgres',
      'USER': 'postgres',
      'HOST': 'db',
      'PORT': 5432,
  }
  }
  </code></pre>
  
  <p>I've seen the post <a href="https://stackoverflow.com/questions/41573313/docker-compose-with-django-could-not-translate-host-name-db-to-address-name-o">here</a> and <a href="https://stackoverflow.com/questions/50552639/running-django-migrations-on-dockerized-project">here</a> however both have not fixed the issue.</p>
  
  <p>Would appreciate some guidance. Thanks.</p>