I am having trouble getting my Postgres-based Django app to run within Docker. Everyone seems to have their own recommendations for the docker-compose.yml, but I have yet to find one that works. Here is the DB setup within settings.py:
DATABASES = {
'default': {
"ENGINE": "django.db.backends.postgresql",
"NAME": "postgres",
"USER": "postgres",
"PASSWORD": "postgres",
"HOST": 'db', # set in docker-compose.yml
"PORT": 5433, # default postgres port
}
}
And here is the docker-compose file:
version: "3"
services:
db:
image: postgres
environment:
POSTGRES_USER: postgres
POSTGRES_DB: postgres
POSTGRES_PASSWORD: postgres
volumes:
- pgdata:/var/lib/posgresql/data
web:
build:
context: .
ports:
- "8000:8000"
volumes:
- .:/LADDER
command: python manage.py runserver 0.0.0.0:8000
depends_on:
- db
volumes:
pgdata:
A basic Docker build does work using this Dockerfile.
base image
FROM python:3.9-slim-bullseye
# The enviroment variable ensures that the python output is set straight
# to the terminal with out buffering it first
ENV PYTHONBUFFERED 1
#directory to store app source code
RUN mkdir /LADDER
#switch to /app directory so that everything runs from here
WORKDIR /LADDER
#copy the app code to image working directory
COPY . /LADDER
#let pip install required packages
RUN pip install -r requirements.txt
# run Django DOESN'T WORK
# ENTRYPOINT ["python", "manage.py"]
# CMD ["runserver", "0.0.0.0:8000"]
Though I am unable to runserver (which is why commented out). Finally, if I run all of this within venv without Docker, the project works fine.
How do I (1) Make sure the server is running and (2) Make sure Django and Postgres are communicating on the same port? My error message suggests a mismatch:
Daniel-mbp-2012 :: Desktop/TENNIS LADDER/LADDER » docker-compose up
[+] Building 0.0s (0/0) docker:desktop-linux
[+] Running 3/3
✔ Network ladder_default Created 0.0s
✔ Container ladder-db-1 Created 0.1s
✔ Container ladder-web-1 Created 0.1s
Attaching to ladder-db-1, ladder-web-1
ladder-db-1 | The files belonging to this database system will be owned by user "postgres".
ladder-db-1 | This user must also own the server process.
ladder-db-1 |
ladder-db-1 | The database cluster will be initialized with locale "en_US.utf8".
ladder-db-1 | The default database encoding has accordingly been set to "UTF8".
ladder-db-1 | The default text search configuration will be set to "english".
ladder-db-1 |
ladder-db-1 | Data page checksums are disabled.
ladder-db-1 |
ladder-db-1 | fixing permissions on existing directory /var/lib/postgresql/data ... ok
ladder-db-1 | creating subdirectories ... ok
ladder-db-1 | selecting dynamic shared memory implementation ... posix
ladder-db-1 | selecting default max_connections ... 100
ladder-db-1 | selecting default shared_buffers ... 128MB
ladder-db-1 | selecting default time zone ... Etc/UTC
ladder-db-1 | creating configuration files ... ok
ladder-db-1 | running bootstrap script ... ok
ladder-db-1 | performing post-bootstrap initialization ... ok
ladder-web-1 | True
ladder-web-1 | BASE_DIR is: /LADDER
ladder-web-1 | TEMPLATE_DIR is: /LADDER/templates
ladder-db-1 | syncing data to disk ... ok
ladder-db-1 |
ladder-db-1 |
ladder-db-1 | Success. You can now start the database server using:
ladder-db-1 |
ladder-db-1 | pg_ctl -D /var/lib/postgresql/data -l logfile start
ladder-db-1 |
ladder-db-1 | initdb: warning: enabling "trust" authentication for local connections
ladder-db-1 | initdb: hint: You can change this by editing pg_hba.conf or using the option -A, or --auth-local and --auth-host, the next time you run initdb.
ladder-db-1 | waiting for server to start....2023-10-18 02:28:20.365 UTC [47] LOG: starting PostgreSQL 16.0 (Debian 16.0-1.pgdg120+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 12.2.0-14) 12.2.0, 64-bit
ladder-db-1 | 2023-10-18 02:28:20.368 UTC [47] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
ladder-db-1 | 2023-10-18 02:28:20.373 UTC [50] LOG: database system was shut down at 2023-10-18 02:28:20 UTC
ladder-db-1 | 2023-10-18 02:28:20.378 UTC [47] LOG: database system is ready to accept connections
ladder-db-1 | done
ladder-db-1 | server started
ladder-db-1 |
ladder-db-1 | /usr/local/bin/docker-entrypoint.sh: ignoring /docker-entrypoint-initdb.d/*
ladder-db-1 |
ladder-db-1 | 2023-10-18 02:28:20.488 UTC [47] LOG: received fast shutdown request
ladder-db-1 | waiting for server to shut down....2023-10-18 02:28:20.490 UTC [47] LOG: aborting any active transactions
ladder-db-1 | 2023-10-18 02:28:20.491 UTC [47] LOG: background worker "logical replication launcher" (PID 53) exited with exit code 1
ladder-db-1 | 2023-10-18 02:28:20.494 UTC [48] LOG: shutting down
ladder-db-1 | 2023-10-18 02:28:20.495 UTC [48] LOG: checkpoint starting: shutdown immediate
ladder-db-1 | 2023-10-18 02:28:20.503 UTC [48] LOG: checkpoint complete: wrote 3 buffers (0.0%); 0 WAL file(s) added, 0 removed, 0 recycled; write=0.003 s, sync=0.002 s, total=0.009 s; sync files=2, longest=0.001 s, average=0.001 s; distance=0 kB, estimate=0 kB; lsn=0/14EAA88, redo lsn=0/14EAA88
ladder-db-1 | 2023-10-18 02:28:20.508 UTC [47] LOG: database system is shut down
ladder-db-1 | done
ladder-db-1 | server stopped
ladder-db-1 |
ladder-db-1 | PostgreSQL init process complete; ready for start up.
ladder-db-1 |
ladder-db-1 | 2023-10-18 02:28:20.611 UTC [1] LOG: starting PostgreSQL 16.0 (Debian 16.0-1.pgdg120+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 12.2.0-14) 12.2.0, 64-bit
ladder-db-1 | 2023-10-18 02:28:20.611 UTC [1] LOG: listening on IPv4 address "0.0.0.0", port 5432
ladder-db-1 | 2023-10-18 02:28:20.611 UTC [1] LOG: listening on IPv6 address "::", port 5432
ladder-db-1 | 2023-10-18 02:28:20.613 UTC [1] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
ladder-db-1 | 2023-10-18 02:28:20.618 UTC [61] LOG: database system was shut down at 2023-10-18 02:28:20 UTC
ladder-db-1 | 2023-10-18 02:28:20.623 UTC [1] LOG: database system is ready to accept connections
ladder-web-1 | True
ladder-web-1 | BASE_DIR is: /LADDER
ladder-web-1 | TEMPLATE_DIR is: /LADDER/templates
ladder-web-1 | Performing system checks...
ladder-web-1 |
ladder-web-1 | Exception in thread django-main-thread:
ladder-web-1 | Traceback (most recent call last):
ladder-web-1 | File "/usr/local/lib/python3.11/site-packages/django/db/backends/base/base.py", line 289, in ensure_connection
ladder-web-1 | self.connect()
ladder-web-1 | File "/usr/local/lib/python3.11/site-packages/django/utils/asyncio.py", line 26, in inner
ladder-web-1 | return func(*args, **kwargs)
ladder-web-1 | ^^^^^^^^^^^^^^^^^^^^^
ladder-web-1 | File "/usr/local/lib/python3.11/site-packages/django/db/backends/base/base.py", line 270, in connect
ladder-web-1 | self.connection = self.get_new_connection(conn_params)
ladder-web-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ladder-web-1 | File "/usr/local/lib/python3.11/site-packages/django/utils/asyncio.py", line 26, in inner
ladder-web-1 | return func(*args, **kwargs)
ladder-web-1 | ^^^^^^^^^^^^^^^^^^^^^
ladder-web-1 | File "/usr/local/lib/python3.11/site-packages/django/db/backends/postgresql/base.py", line 275, in get_new_connection
ladder-web-1 | connection = self.Database.connect(**conn_params)
ladder-web-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ladder-web-1 | File "/usr/local/lib/python3.11/site-packages/psycopg2/__init__.py", line 122, in connect
ladder-web-1 | conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
ladder-web-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ladder-web-1 | psycopg2.OperationalError: connection to server on socket "/var/run/postgresql/.s.PGSQL.5433" failed: No such file or directory
ladder-web-1 | Is the server running locally and accepting connections on that socket?
ladder-web-1 |
ladder-web-1 |
ladder-web-1 | The above exception was the direct cause of the following exception:
ladder-web-1 |
ladder-web-1 | Traceback (most recent call last):
ladder-web-1 | File "/usr/local/lib/python3.11/threading.py", line 1038, in _bootstrap_inner
ladder-web-1 | self.run()
ladder-web-1 | File "/usr/local/lib/python3.11/threading.py", line 975, in run
ladder-web-1 | self._target(*self._args, **self._kwargs)
ladder-web-1 | File "/usr/local/lib/python3.11/site-packages/django/utils/autoreload.py", line 64, in wrapper
ladder-web-1 | fn(*args, **kwargs)
ladder-web-1 | File "/usr/local/lib/python3.11/site-packages/django/core/management/commands/runserver.py", line 133, in inner_run
ladder-web-1 | self.check(display_num_errors=True)
ladder-web-1 | File "/usr/local/lib/python3.11/site-packages/django/core/management/base.py", line 485, in check
ladder-web-1 | all_issues = checks.run_checks(
ladder-web-1 | ^^^^^^^^^^^^^^^^^^
ladder-web-1 | File "/usr/local/lib/python3.11/site-packages/django/core/checks/registry.py", line 88, in run_checks
ladder-web-1 | new_errors = check(app_configs=app_configs, databases=databases)
ladder-web-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ladder-web-1 | File "/usr/local/lib/python3.11/site-packages/django/core/checks/urls.py", line 14, in check_url_config
ladder-web-1 | return check_resolver(resolver)
ladder-web-1 | ^^^^^^^^^^^^^^^^^^^^^^^^
ladder-web-1 | File "/usr/local/lib/python3.11/site-packages/django/core/checks/urls.py", line 24, in check_resolver
ladder-web-1 | return check_method()
ladder-web-1 | ^^^^^^^^^^^^^^
ladder-web-1 | File "/usr/local/lib/python3.11/site-packages/django/urls/resolvers.py", line 494, in check
ladder-web-1 | for pattern in self.url_patterns:
ladder-web-1 | ^^^^^^^^^^^^^^^^^
ladder-web-1 | File "/usr/local/lib/python3.11/site-packages/django/utils/functional.py", line 57, in __get__
ladder-web-1 | res = instance.__dict__[self.name] = self.func(instance)
ladder-web-1 | ^^^^^^^^^^^^^^^^^^^
ladder-web-1 | File "/usr/local/lib/python3.11/site-packages/django/urls/resolvers.py", line 715, in url_patterns
ladder-web-1 | patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
ladder-web-1 | ^^^^^^^^^^^^^^^^^^^
ladder-web-1 | File "/usr/local/lib/python3.11/site-packages/django/utils/functional.py", line 57, in __get__
ladder-web-1 | res = instance.__dict__[self.name] = self.func(instance)
ladder-web-1 | ^^^^^^^^^^^^^^^^^^^
ladder-web-1 | File "/usr/local/lib/python3.11/site-packages/django/urls/resolvers.py", line 708, in urlconf_module
ladder-web-1 | return import_module(self.urlconf_name)
ladder-web-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ladder-web-1 | File "/usr/local/lib/python3.11/importlib/__init__.py", line 126, in import_module
ladder-web-1 | return _bootstrap._gcd_import(name[level:], package, level)
ladder-web-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ladder-web-1 | File "<frozen importlib._bootstrap>", line 1204, in _gcd_import
ladder-web-1 | File "<frozen importlib._bootstrap>", line 1176, in _find_and_load
ladder-web-1 | File "<frozen importlib._bootstrap>", line 1147, in _find_and_load_unlocked
ladder-web-1 | File "<frozen importlib._bootstrap>", line 690, in _load_unlocked
ladder-web-1 | File "<frozen importlib._bootstrap_external>", line 940, in exec_module
ladder-web-1 | File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
ladder-web-1 | File "/LADDER/ladder/urls.py", line 22, in <module>
ladder-web-1 | path('', include('players.urls')),
ladder-web-1 | ^^^^^^^^^^^^^^^^^^^^^^^
ladder-web-1 | File "/usr/local/lib/python3.11/site-packages/django/urls/conf.py", line 38, in include
ladder-web-1 | urlconf_module = import_module(urlconf_module)
ladder-web-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ladder-web-1 | File "/usr/local/lib/python3.11/importlib/__init__.py", line 126, in import_module
ladder-web-1 | return _bootstrap._gcd_import(name[level:], package, level)
ladder-web-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ladder-web-1 | File "<frozen importlib._bootstrap>", line 1204, in _gcd_import
ladder-web-1 | File "<frozen importlib._bootstrap>", line 1176, in _find_and_load
ladder-web-1 | File "<frozen importlib._bootstrap>", line 1147, in _find_and_load_unlocked
ladder-web-1 | File "<frozen importlib._bootstrap>", line 690, in _load_unlocked
ladder-web-1 | File "<frozen importlib._bootstrap_external>", line 940, in exec_module
ladder-web-1 | File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
ladder-web-1 | File "/LADDER/players/urls.py", line 2, in <module>
ladder-web-1 | from .views import HomePageView, PlayerListView, PlayerDetailView, \
ladder-web-1 | File "/LADDER/players/views.py", line 45, in <module>
ladder-web-1 | class PlayerCreateView(PermissionRequiredMixin, CreateView):
ladder-web-1 | File "/LADDER/players/views.py", line 48, in PlayerCreateView
ladder-web-1 | num_players = Player.objects.count()
ladder-web-1 | ^^^^^^^^^^^^^^^^^^^^^^
ladder-web-1 | File "/usr/local/lib/python3.11/site-packages/django/db/models/manager.py", line 87, in manager_method
ladder-web-1 | return getattr(self.get_queryset(), name)(*args, **kwargs)
ladder-web-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ladder-web-1 | File "/usr/local/lib/python3.11/site-packages/django/db/models/query.py", line 608, in count
ladder-web-1 | return self.query.get_count(using=self.db)
ladder-web-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ladder-web-1 | File "/usr/local/lib/python3.11/site-packages/django/db/models/sql/query.py", line 568, in get_count
ladder-web-1 | return obj.get_aggregation(using, {"__count": Count("*")})["__count"]
ladder-web-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ladder-web-1 | File "/usr/local/lib/python3.11/site-packages/django/db/models/sql/query.py", line 554, in get_aggregation
ladder-web-1 | result = compiler.execute_sql(SINGLE)
ladder-web-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ladder-web-1 | File "/usr/local/lib/python3.11/site-packages/django/db/models/sql/compiler.py", line 1560, in execute_sql
ladder-web-1 | cursor = self.connection.cursor()
ladder-web-1 | ^^^^^^^^^^^^^^^^^^^^^^^^
ladder-web-1 | File "/usr/local/lib/python3.11/site-packages/django/utils/asyncio.py", line 26, in inner
ladder-web-1 | return func(*args, **kwargs)
ladder-web-1 | ^^^^^^^^^^^^^^^^^^^^^
ladder-web-1 | File "/usr/local/lib/python3.11/site-packages/django/db/backends/base/base.py", line 330, in cursor
ladder-web-1 | return self._cursor()
ladder-web-1 | ^^^^^^^^^^^^^^
ladder-web-1 | File "/usr/local/lib/python3.11/site-packages/django/db/backends/base/base.py", line 306, in _cursor
ladder-web-1 | self.ensure_connection()
ladder-web-1 | File "/usr/local/lib/python3.11/site-packages/django/utils/asyncio.py", line 26, in inner
ladder-web-1 | return func(*args, **kwargs)
ladder-web-1 | ^^^^^^^^^^^^^^^^^^^^^
ladder-web-1 | File "/usr/local/lib/python3.11/site-packages/django/db/backends/base/base.py", line 288, in ensure_connection
ladder-web-1 | with self.wrap_database_errors:
ladder-web-1 | File "/usr/local/lib/python3.11/site-packages/django/db/utils.py", line 91, in __exit__
ladder-web-1 | raise dj_exc_value.with_traceback(traceback) from exc_value
ladder-web-1 | File "/usr/local/lib/python3.11/site-packages/django/db/backends/base/base.py", line 289, in ensure_connection
ladder-web-1 | self.connect()
ladder-web-1 | File "/usr/local/lib/python3.11/site-packages/django/utils/asyncio.py", line 26, in inner
ladder-web-1 | return func(*args, **kwargs)
ladder-web-1 | ^^^^^^^^^^^^^^^^^^^^^
ladder-web-1 | File "/usr/local/lib/python3.11/site-packages/django/db/backends/base/base.py", line 270, in connect
ladder-web-1 | self.connection = self.get_new_connection(conn_params)
ladder-web-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ladder-web-1 | File "/usr/local/lib/python3.11/site-packages/django/utils/asyncio.py", line 26, in inner
ladder-web-1 | return func(*args, **kwargs)
ladder-web-1 | ^^^^^^^^^^^^^^^^^^^^^
ladder-web-1 | File "/usr/local/lib/python3.11/site-packages/django/db/backends/postgresql/base.py", line 275, in get_new_connection
ladder-web-1 | connection = self.Database.connect(**conn_params)
ladder-web-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ladder-web-1 | File "/usr/local/lib/python3.11/site-packages/psycopg2/__init__.py", line 122, in connect
ladder-web-1 | conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
ladder-web-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ladder-web-1 | django.db.utils.OperationalError: connection to server on socket "/var/run/postgresql/.s.PGSQL.5433" failed: No such file or directory
ladder-web-1 | Is the server running locally and accepting connections on that socket?
ladder-web-1 |
ladder-web-1 | True
ladder-web-1 | BASE_DIR is: /LADDER
ladder-web-1 | TEMPLATE_DIR is: /LADDER/templates
ladder-web-1 | Performing system checks...
ladder-web-1 |
ladder-web-1 | Exception in thread django-main-thread:
ladder-web-1 | Traceback (most recent call last):
ladder-web-1 | File "/usr/local/lib/python3.11/site-packages/django/db/backends/base/base.py", line 289, in ensure_connection
ladder-web-1 | self.connect()
ladder-web-1 | File "/usr/local/lib/python3.11/site-packages/django/utils/asyncio.py", line 26, in inner
ladder-web-1 | return func(*args, **kwargs)
ladder-web-1 | ^^^^^^^^^^^^^^^^^^^^^
ladder-web-1 | File "/usr/local/lib/python3.11/site-packages/django/db/backends/base/base.py", line 270, in connect
ladder-web-1 | self.connection = self.get_new_connection(conn_params)
ladder-web-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ladder-web-1 | File "/usr/local/lib/python3.11/site-packages/django/utils/asyncio.py", line 26, in inner
ladder-web-1 | return func(*args, **kwargs)
ladder-web-1 | ^^^^^^^^^^^^^^^^^^^^^
ladder-web-1 | File "/usr/local/lib/python3.11/site-packages/django/db/backends/postgresql/base.py", line 275, in get_new_connection
ladder-web-1 | connection = self.Database.connect(**conn_params)
ladder-web-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ladder-web-1 | File "/usr/local/lib/python3.11/site-packages/psycopg2/__init__.py", line 122, in connect
ladder-web-1 | conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
ladder-web-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ladder-web-1 | psycopg2.OperationalError: connection to server at "db" (172.20.0.2), port 5433 failed: Connection refused
ladder-web-1 | Is the server running on that host and accepting TCP/IP connections?
ladder-web-1 |
ladder-web-1 |
ladder-web-1 | The above exception was the direct cause of the following exception:
ladder-web-1 |
ladder-web-1 | Traceback (most recent call last):
ladder-web-1 | File "/usr/local/lib/python3.11/threading.py", line 1038, in _bootstrap_inner
ladder-web-1 | self.run()
ladder-web-1 | File "/usr/local/lib/python3.11/threading.py", line 975, in run
ladder-web-1 | self._target(*self._args, **self._kwargs)
ladder-web-1 | File "/usr/local/lib/python3.11/site-packages/django/utils/autoreload.py", line 64, in wrapper
ladder-web-1 | fn(*args, **kwargs)
ladder-web-1 | File "/usr/local/lib/python3.11/site-packages/django/core/management/commands/runserver.py", line 133, in inner_run
ladder-web-1 | self.check(display_num_errors=True)
ladder-web-1 | File "/usr/local/lib/python3.11/site-packages/django/core/management/base.py", line 485, in check
ladder-web-1 | all_issues = checks.run_checks(
ladder-web-1 | ^^^^^^^^^^^^^^^^^^
ladder-web-1 | File "/usr/local/lib/python3.11/site-packages/django/core/checks/registry.py", line 88, in run_checks
ladder-web-1 | new_errors = check(app_configs=app_configs, databases=databases)
ladder-web-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ladder-web-1 | File "/usr/local/lib/python3.11/site-packages/django/core/checks/urls.py", line 14, in check_url_config
ladder-web-1 | return check_resolver(resolver)
ladder-web-1 | ^^^^^^^^^^^^^^^^^^^^^^^^
ladder-web-1 | File "/usr/local/lib/python3.11/site-packages/django/core/checks/urls.py", line 24, in check_resolver
ladder-web-1 | return check_method()
ladder-web-1 | ^^^^^^^^^^^^^^
ladder-web-1 | File "/usr/local/lib/python3.11/site-packages/django/urls/resolvers.py", line 494, in check
ladder-web-1 | for pattern in self.url_patterns:
ladder-web-1 | ^^^^^^^^^^^^^^^^^
ladder-web-1 | File "/usr/local/lib/python3.11/site-packages/django/utils/functional.py", line 57, in __get__
ladder-web-1 | res = instance.__dict__[self.name] = self.func(instance)
ladder-web-1 | ^^^^^^^^^^^^^^^^^^^
ladder-web-1 | File "/usr/local/lib/python3.11/site-packages/django/urls/resolvers.py", line 715, in url_patterns
ladder-web-1 | patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
ladder-web-1 | ^^^^^^^^^^^^^^^^^^^
ladder-web-1 | File "/usr/local/lib/python3.11/site-packages/django/utils/functional.py", line 57, in __get__
ladder-web-1 | res = instance.__dict__[self.name] = self.func(instance)
ladder-web-1 | ^^^^^^^^^^^^^^^^^^^
ladder-web-1 | File "/usr/local/lib/python3.11/site-packages/django/urls/resolvers.py", line 708, in urlconf_module
ladder-web-1 | return import_module(self.urlconf_name)
ladder-web-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ladder-web-1 | File "/usr/local/lib/python3.11/importlib/__init__.py", line 126, in import_module
ladder-web-1 | return _bootstrap._gcd_import(name[level:], package, level)
ladder-web-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ladder-web-1 | File "<frozen importlib._bootstrap>", line 1204, in _gcd_import
ladder-web-1 | File "<frozen importlib._bootstrap>", line 1176, in _find_and_load
ladder-web-1 | File "<frozen importlib._bootstrap>", line 1147, in _find_and_load_unlocked
ladder-web-1 | File "<frozen importlib._bootstrap>", line 690, in _load_unlocked
ladder-web-1 | File "<frozen importlib._bootstrap_external>", line 940, in exec_module
ladder-web-1 | File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
ladder-web-1 | File "/LADDER/ladder/urls.py", line 22, in <module>
ladder-web-1 | path('', include('players.urls')),
ladder-web-1 | ^^^^^^^^^^^^^^^^^^^^^^^
ladder-web-1 | File "/usr/local/lib/python3.11/site-packages/django/urls/conf.py", line 38, in include
ladder-web-1 | urlconf_module = import_module(urlconf_module)
ladder-web-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ladder-web-1 | File "/usr/local/lib/python3.11/importlib/__init__.py", line 126, in import_module
ladder-web-1 | return _bootstrap._gcd_import(name[level:], package, level)
ladder-web-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ladder-web-1 | File "<frozen importlib._bootstrap>", line 1204, in _gcd_import
ladder-web-1 | File "<frozen importlib._bootstrap>", line 1176, in _find_and_load
ladder-web-1 | File "<frozen importlib._bootstrap>", line 1147, in _find_and_load_unlocked
ladder-web-1 | File "<frozen importlib._bootstrap>", line 690, in _load_unlocked
ladder-web-1 | File "<frozen importlib._bootstrap_external>", line 940, in exec_module
ladder-web-1 | File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
ladder-web-1 | File "/LADDER/players/urls.py", line 2, in <module>
ladder-web-1 | from .views import HomePageView, PlayerListView, PlayerDetailView, \
ladder-web-1 | File "/LADDER/players/views.py", line 45, in <module>
ladder-web-1 | class PlayerCreateView(PermissionRequiredMixin, CreateView):
ladder-web-1 | File "/LADDER/players/views.py", line 48, in PlayerCreateView
ladder-web-1 | num_players = Player.objects.count()
ladder-web-1 | ^^^^^^^^^^^^^^^^^^^^^^
ladder-web-1 | File "/usr/local/lib/python3.11/site-packages/django/db/models/manager.py", line 87, in manager_method
ladder-web-1 | return getattr(self.get_queryset(), name)(*args, **kwargs)
ladder-web-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ladder-web-1 | File "/usr/local/lib/python3.11/site-packages/django/db/models/query.py", line 608, in count
ladder-web-1 | return self.query.get_count(using=self.db)
ladder-web-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ladder-web-1 | File "/usr/local/lib/python3.11/site-packages/django/db/models/sql/query.py", line 568, in get_count
ladder-web-1 | return obj.get_aggregation(using, {"__count": Count("*")})["__count"]
ladder-web-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ladder-web-1 | File "/usr/local/lib/python3.11/site-packages/django/db/models/sql/query.py", line 554, in get_aggregation
ladder-web-1 | result = compiler.execute_sql(SINGLE)
ladder-web-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ladder-web-1 | File "/usr/local/lib/python3.11/site-packages/django/db/models/sql/compiler.py", line 1560, in execute_sql
ladder-web-1 | cursor = self.connection.cursor()
ladder-web-1 | ^^^^^^^^^^^^^^^^^^^^^^^^
ladder-web-1 | File "/usr/local/lib/python3.11/site-packages/django/utils/asyncio.py", line 26, in inner
ladder-web-1 | return func(*args, **kwargs)
ladder-web-1 | ^^^^^^^^^^^^^^^^^^^^^
ladder-web-1 | File "/usr/local/lib/python3.11/site-packages/django/db/backends/base/base.py", line 330, in cursor
ladder-web-1 | return self._cursor()
ladder-web-1 | ^^^^^^^^^^^^^^
ladder-web-1 | File "/usr/local/lib/python3.11/site-packages/django/db/backends/base/base.py", line 306, in _cursor
ladder-web-1 | self.ensure_connection()
ladder-web-1 | File "/usr/local/lib/python3.11/site-packages/django/utils/asyncio.py", line 26, in inner
ladder-web-1 | return func(*args, **kwargs)
ladder-web-1 | ^^^^^^^^^^^^^^^^^^^^^
ladder-web-1 | File "/usr/local/lib/python3.11/site-packages/django/db/backends/base/base.py", line 288, in ensure_connection
ladder-web-1 | with self.wrap_database_errors:
ladder-web-1 | File "/usr/local/lib/python3.11/site-packages/django/db/utils.py", line 91, in __exit__
ladder-web-1 | raise dj_exc_value.with_traceback(traceback) from exc_value
ladder-web-1 | File "/usr/local/lib/python3.11/site-packages/django/db/backends/base/base.py", line 289, in ensure_connection
ladder-web-1 | self.connect()
ladder-web-1 | File "/usr/local/lib/python3.11/site-packages/django/utils/asyncio.py", line 26, in inner
ladder-web-1 | return func(*args, **kwargs)
ladder-web-1 | ^^^^^^^^^^^^^^^^^^^^^
ladder-web-1 | File "/usr/local/lib/python3.11/site-packages/django/db/backends/base/base.py", line 270, in connect
ladder-web-1 | self.connection = self.get_new_connection(conn_params)
ladder-web-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ladder-web-1 | File "/usr/local/lib/python3.11/site-packages/django/utils/asyncio.py", line 26, in inner
ladder-web-1 | return func(*args, **kwargs)
ladder-web-1 | ^^^^^^^^^^^^^^^^^^^^^
ladder-web-1 | File "/usr/local/lib/python3.11/site-packages/django/db/backends/postgresql/base.py", line 275, in get_new_connection
ladder-web-1 | connection = self.Database.connect(**conn_params)
ladder-web-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ladder-web-1 | File "/usr/local/lib/python3.11/site-packages/psycopg2/__init__.py", line 122, in connect
ladder-web-1 | conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
ladder-web-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ladder-web-1 | django.db.utils.OperationalError: connection to server at "db" (172.20.0.2), port 5433 failed: Connection refused
ladder-web-1 | Is the server running on that host and accepting TCP/IP connections?
ladder-web-1 |