I have set up a few models in a simple django project. When I run
python manage.py sql fivefives
I get loads of nice looking sql, when I run syncdb or validate I get 0 errors.
BEGIN;
CREATE TABLE "fivefives_player" (
"id" serial NOT NULL PRIMARY KEY,
"username" varchar(200) NOT NULL,
"colour" varchar(7) NOT NULL,
"remaining_dice" integer NOT NULL
)
;
CREATE TABLE "fivefives_game_player_list" (
"id" serial NOT NULL PRIMARY KEY,
"game_id" integer NOT NULL,
"player_id" integer NOT NULL REFERENCES "fivefives_player" ("id") DEFERRABLE INITIALLY DEFERRED,
UNIQUE ("game_id", "player_id")
)
;
CREATE TABLE "fivefives_game" (
"id" serial NOT NULL PRIMARY KEY,
"time" timestamp with time zone NOT NULL
)
;
ALTER TABLE "fivefives_game_player_list" ADD CONSTRAINT "game_id_refs_id_c39af54" FOREIGN KEY ("game_id") REFERENCES "fivefives_game" ("id") DEFERRABLE INITIALLY DEFERRED;
CREATE TABLE "fivefives_round_player_list" (
"id" serial NOT NULL PRIMARY KEY,
"round_id" integer NOT NULL,
"player_id" integer NOT NULL REFERENCES "fivefives_player" ("id") DEFERRABLE INITIALLY DEFERRED,
UNIQUE ("round_id", "player_id")
)
; ... it continues like this...
But as soon as I hop into admin the tables aren’t there. Logging into postgres I see the tables haven’t even been created.
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
'NAME': 'perudodb', # Or path to database file if using sqlite3.
'USER': 'postgres', # Not used with sqlite3.
'PASSWORD': 'postgres', # Not used with sqlite3.
'HOST': '', # Set to empty string for localhost. Not used with sqlite3.
'PORT': '', # Set to empty string for default. Not used with sqlite3.
}
}
Anyone come up with anything like this before? Just copied all files onto my friends computer and syncdb’d and it all works great.
To actually create the tables, you want
manage.py syncdb.