#33556: Django Error Connecting to Postgres DB on Docker
-------------------------------------+-------------------------------------
               Reporter:  Adebayo    |          Owner:  nobody
  Osinulu                            |
                   Type:  Bug        |         Status:  new
              Component:  Database   |        Version:  4.0
  layer (models, ORM)                |
               Severity:  Normal     |       Keywords:
           Triage Stage:             |      Has patch:  0
  Unreviewed                         |
    Needs documentation:  0          |    Needs tests:  0
Patch needs improvement:  0          |  Easy pickings:  0
                  UI/UX:  0          |
-------------------------------------+-------------------------------------
 I started a simple Dockerized django app, however, when I tried to connect
 to the DB (PostgreSQL, also on Docker) I get this error

 {{{

 ERROR:  column c.relispartition does not exist at character 54
 db_1   | STATEMENT:
 db_1   |                    SELECT c.relname,
 db_1   |                    CASE WHEN c.relispartition THEN 'p' WHEN
 c.relkind IN ('m', 'v') THEN 'v' ELSE 't' END
 db_1   |                    FROM pg_catalog.pg_class c
 db_1   |                    LEFT JOIN pg_catalog.pg_namespace n ON n.oid =
 c.relnamespace
 db_1   |                    WHERE c.relkind IN ('f', 'm', 'p', 'r', 'v')
 db_1   |                        AND n.nspname NOT IN ('pg_catalog',
 'pg_toast')
 db_1   |                        AND pg_catalog.pg_table_is_visible(c.oid)
 db_1   |
 web_1  | Exception in thread django-main-thread:
 web_1  | Traceback (most recent call last):
 web_1  |   File "/usr/local/lib/python3.8/site-
 packages/django/db/backends/utils.py", line 83, in _execute
 web_1  |     return self.cursor.execute(sql)
 web_1  | psycopg2.errors.UndefinedColumn: column c.relispartition does not
 exist
 web_1  | LINE 3:             CASE WHEN c.relispartition THEN 'p' WHEN
 c.relki...
 web_1  |                               ^
 web_1  |
 web_1  |
 web_1  | The above exception was the direct cause of the following
 exception:
 web_1  |
 web_1  | Traceback (most recent call last):
 web_1  |   File "/usr/local/lib/python3.8/threading.py", line 932, in
 _bootstrap_inner
 web_1  |     self.run()
 web_1  |   File "/usr/local/lib/python3.8/threading.py", line 870, in run
 web_1  |     self._target(*self._args, **self._kwargs)
 web_1  |   File "/usr/local/lib/python3.8/site-
 packages/django/utils/autoreload.py", line 64, in wrapper
 web_1  |     fn(*args, **kwargs)
 web_1  |   File "/usr/local/lib/python3.8/site-
 packages/channels/management/commands/runserver.py", line 76, in inner_run
 web_1  |     self.check_migrations()
 web_1  |   File "/usr/local/lib/python3.8/site-
 packages/django/core/management/base.py", line 505, in check_migrations
 web_1  |     executor = MigrationExecutor(connections[DEFAULT_DB_ALIAS])
 web_1  |   File "/usr/local/lib/python3.8/site-
 packages/django/db/migrations/executor.py", line 18, in __init__
 web_1  |     self.loader = MigrationLoader(self.connection)
 web_1  |   File "/usr/local/lib/python3.8/site-
 packages/django/db/migrations/loader.py", line 53, in __init__
 web_1  |     self.build_graph()
 web_1  |   File "/usr/local/lib/python3.8/site-
 packages/django/db/migrations/loader.py", line 223, in build_graph
 web_1  |     self.applied_migrations = recorder.applied_migrations()
 web_1  |   File "/usr/local/lib/python3.8/site-
 packages/django/db/migrations/recorder.py", line 77, in applied_migrations
 web_1  |     if self.has_table():
 web_1  |   File "/usr/local/lib/python3.8/site-
 packages/django/db/migrations/recorder.py", line 56, in has_table
 web_1  |     tables = self.connection.introspection.table_names(cursor)
 web_1  |   File "/usr/local/lib/python3.8/site-
 packages/django/db/backends/base/introspection.py", line 52, in
 table_names
 web_1  |     return get_names(cursor)
 web_1  |   File "/usr/local/lib/python3.8/site-
 packages/django/db/backends/base/introspection.py", line 47, in get_names
 web_1  |     return sorted(ti.name for ti in self.get_table_list(cursor)
 web_1  |   File "/usr/local/lib/python3.8/site-
 packages/django/db/backends/postgresql/introspection.py", line 49, in
 get_table_list
 web_1  |     cursor.execute("""
 web_1  |   File "/usr/local/lib/python3.8/site-
 packages/django/db/backends/utils.py", line 99, in execute
 web_1  |     return super().execute(sql, params)
 web_1  |   File "/usr/local/lib/python3.8/site-
 packages/django/db/backends/utils.py", line 67, in execute
 web_1  |     return self._execute_with_wrappers(sql, params, many=False,
 executor=self._execute)
 web_1  |   File "/usr/local/lib/python3.8/site-
 packages/django/db/backends/utils.py", line 76, in _execute_with_wrappers
 web_1  |     return executor(sql, params, many, context)
 web_1  |   File "/usr/local/lib/python3.8/site-
 packages/django/db/backends/utils.py", line 85, in _execute
 web_1  |     return self.cursor.execute(sql, params)
 web_1  |   File "/usr/local/lib/python3.8/site-
 packages/django/db/utils.py", line 90, in __exit__
 web_1  |     raise dj_exc_value.with_traceback(traceback) from exc_value
 web_1  |   File "/usr/local/lib/python3.8/site-
 packages/django/db/backends/utils.py", line 83, in _execute
 web_1  |     return self.cursor.execute(sql)
 web_1  | django.db.utils.ProgrammingError: column c.relispartition does
 not exist
 web_1  | LINE 3:             CASE WHEN c.relispartition THEN 'p' WHEN
 c.relki...
 web_1  |                               ^


 }}}

 The bug seems to emanate from utils.py in /django/db/backends/

 Downgrading Django version to 3.2 provides a temporary fix, upon upgrading
 to 4.0 issue persist.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/33556>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/0107017f59d0d3bd-02341822-307c-4d49-85ea-e465f1ae73ad-000000%40eu-central-1.amazonses.com.

Reply via email to