You just need to configure your Django settings before making any calls, including importing your models. Something like that:
from django.conf import settings settings.configure( DATABASE_ENGINE = 'postgresql_psycopg2', DATABASE_NAME = 'db_name', DATABASE_USER = 'db_user', DATABASE_PASSWORD = 'db_pass', DATABASE_HOST = 'localhost', DATABASE_PORT = '5432', TIME_ZONE = 'America/New_York', )
Again, be sure to run this code before running, for example:
from your_app.models import *
Then just use the DB API as usual.
FogleBird Feb 01 '10 at 10:08
source share