shaare.it

ProgrammingError: relation does not exist due to search_path

7 Dec 2025

1 min read

ProgrammingError: relation does not exist due to search_path

$ python manage.py migrate
...
ProgrammingError: relation "public.app_model" does not exist

Why this happens

DB uses schemas and search_path doesn’t include the schema where tables were created.

Fix

Adjust DB user search_path or set OPTIONS in DATABASES to specify schema.

Wrong code

DATABASES['default']['OPTIONS'] = {}

Fixed code

DATABASES['default']['OPTIONS'] = {
    'options': '-c search_path=public'
}