1
如何在保存記錄時避免在模型上進行foreingkey檢查,因爲這會產生2個額外的查詢,並且我需要應用程序的速度。Django,避免在模型上進行forekey檢查
SELECT (1) AS "a" FROM "auth_user" WHERE "auth_user"."id" = 1 LIMIT 1
和
SELECT "auth_user"."id", "auth_user"."password", "auth_user"."last_login", "auth_user"."is_superuser", "auth_user"."username", "auth_user"."first_name", "auth_user"."last_name", "auth_user"."email", "auth_user"."is_staff", "auth_user"."is_active", "auth_user"."date_joined" FROM "auth_user" WHERE "auth_user"."id" = 1
我試過你的例子,但這不起作用。我正在使用postgreSQL,Django 1.6c1和Python 2.7.4 –
這些查詢是否在記錄保存的任何時候運行? –
是的,當我調用modelform「myModelForm.save()」 –