仅适用于 Postgres:对于外键限制,您可以使用 Truncate Cascade,这也会截断所有相关表。 cursor.execute('TRUNCATE TABLE "{0}" CASCADE'.format(MyModel._meta.db_table)) 10投票 除了Ned Batchelder 的回答并参考 Bernhard Kircher 的评论: 就我而言,我需要使用网络应用程序清空一个非常大的数据库: Book.obj...
DETAIL: Table"users"references"tenants". HINT: Truncate table"users"at the same time, or use TRUNCATE ... CASCADE. Caused by: PG::FeatureNotSupported: ERROR: cannot truncate a table referencedina foreign key constraint (PG::FeatureNotSupported) DETAIL: Table"users"references"platform_tenants". ...