我有一個Django應用程序,我使用的是postgres。我嘗試在我的測試一個執行bollowing行:Django的PostgreSQL問題
print BillingUser.objects.all()
而且我得到以下錯誤:
"current transaction is aborted, commands ignored until end of transaction block."
我postresql日誌:
ERROR: duplicate key value violates unique constraint "billing_rental_wallet_id_key"
STATEMENT: INSERT INTO "billing_rental" ("wallet_id", "item_id", "end_time", "time", "value", "index", "info") VALUES (61, 230, E'2010-02-11 11:01:01.092336', E'2010-02-01 11:01:01.092336', 10.0, 1, NULL)
ERROR: current transaction is aborted, commands ignored until end of transaction block
STATEMENT: INSERT INTO "billing_timeable" ("creation_date", "update_date") VALUES (E'2010-02-01 11:01:01.093504', E'2010-02-01 11:01:01.093531')
ERROR: current transaction is aborted, commands ignored until end of transaction block
STATEMENT: SELECT "billing_timeable"."id", "billing_timeable"."creation_date", "billing_timeable"."update_date", "billing_billinguser"."timeable_ptr_id", "billing_billinguser"."username", "billing_billinguser"."pin", "billing_billinguser"."sbox_id", "billing_billinguser"."parental_code", "billing_billinguser"."active" FROM "billing_billinguser" INNER JOIN "billing_timeable" ON ("billing_billinguser"."timeable_ptr_id" = "billing_timeable"."id") LIMIT 21
我怎樣才能解決這個問題?
謝謝,Arshavski亞歷山大。
你確定你沒有試圖插入這個打印線上方的某處嗎?你是否覆蓋了'BillingUser'類中的任何方法?更多的代碼將會非常有用。 – 2010-02-01 09:27:55
我的tests.py在這裏:slexy.org/view/s21qJe144O我的models.py在這裏:slexy.org/view/s21EaSv1yu – alexarsh 2010-02-01 09:35:30
在這行打印命令? – 2010-02-01 10:24:54