Could not translate host name in Docker Compose with the same network in different yaml files

First i create backend network:

docker network create backend

Create first docker-compose.yaml file with db:

version: '3.8'

services:
  db:
    image: postgres
    restart: always
    environment:
      POSTGRES_PASSWORD: postgres
    ports:
      - "5432:5432"      
    networks: 
      - backend
      
networks:
  backend:
    external: true

Create second docker-compose.yaml file with Django:

version: '3.8'

services:
  django:
    build:
      context: ./
      dockerfile: ./dockerfiles/django
    restart: always
    command: python3 manage.py runserver 0.0.0.0:8000
    ports:
      - "80:8000"
    networks:
      - backend
    volumes:
      - .:/code

networks:
  backend:
    external: true

DB settings in Django:

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql',
        'NAME': 'db_name',
        'USER': 'user_name',
        'PASSWORD': 'user_pass',
        'HOST': 'backend',
        'PORT': '5432',
    }
}

Docker compose up on Django yaml:

django.db.utils.OperationalError: could not translate host name "backend" to address: Name or service not known

I read docs and other questions… I’m definitely doing everything right, but why django can’t resolve host name? I try docker-compose run and docker-compose up but nothing helped.

Also i try getent in both containers(django and db) but output is empty:

getent hosts backend

I looked at the /etc/hosts but it does not have backend

But docker inspect backend show me in "Containers" that the both services are connected to the network

"Containers": {
    "25c5cc71f1c66dd3c8540783c08532f32073859b6a1afdc4fe4efd1236963080": {
        "Name": "worker_django_1",
        "EndpointID": "e982e75232e5d920bf3b053fce36b85589d4d7d9d8c5a8fbaea4a76dba519aa0",
        "MacAddress": "02:42:ac:13:00:03",
        "IPv4Address": "172.19.0.3/16",
        "IPv6Address": ""
    },
    "6a7447068f0d5c9ba725b02e46f243aaac1ebca2068c978c7a183f965a3460fe": {
        "Name": "postgres_db_1",
        "EndpointID": "e3977c3f26a583a9117f7504f4a6ed0f192cdc88e872e129108a90f419b755b0",
        "MacAddress": "02:42:ac:13:00:02",
        "IPv4Address": "172.19.0.2/16",
        "IPv6Address": ""
    }
},

Source: Docker Questions