Skip to content

Instantly share code, notes, and snippets.

@cbess
Created June 17, 2011 16:00
Show Gist options
  • Save cbess/1031701 to your computer and use it in GitHub Desktop.
Save cbess/1031701 to your computer and use it in GitHub Desktop.
django 1.3 postgresql schema (search path) fix for inspectdb and db connection
= Modify: django.core.management.commands.inspectdb
- line 33, add
- cursor.execute("SET search_path TO myschema")
- line 80, change to
- field_type = 'ForeignKey(\'%s\'' % rel_to
- now you can ignore the model ordering
= Modify: django.db.backends.postgres_psycopg2.base
- line 147, add
- cursor.execute("SET search_path TO myschema")
- You may need to add the above line to lines 46 and 55, so that it happens during each execute
- C. Bess
@cbess
Copy link
Author

cbess commented Jun 17, 2011

I tested/used this in a production env (and it works)

@cbess
Copy link
Author

cbess commented Jun 17, 2011

@cbess
Copy link
Author

cbess commented Jun 20, 2011

Had to add set search path to each execute call, for some reason it still couldn't find a few table relations. This is just for a database import script, so I'll sprinkle that line where ever its needed, for now.

@nareshguggilla
Copy link

Any idea about how to fix the search path in 1.8?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment