When a migration starts with custom table names which have foreign keys to other app; that then get renamed to django default tables later on, the flush command breaks.
The full error: cannot truncate a table referenced in a foreign key constraint
DETAIL: Table "table_A" references "table_B".
HINT: Truncate table "table_A" at the same time, or use TRUNCATE ... CASCADE.
The error is caused perhaps by django's own code, since the flush command doesn't add the custom table names to the list of tables to flush. Setting only_django to False will fix the issue since the introspection module will correctly list lal the tables.
When a migration starts with custom table names which have foreign keys to other app; that then get renamed to django default tables later on, the flush command breaks.
The full error: cannot truncate a table referenced in a foreign key constraint
DETAIL: Table "table_A" references "table_B".
HINT: Truncate table "table_A" at the same time, or use TRUNCATE ... CASCADE.
The error is caused perhaps by django's own code, since the flush command doesn't add the custom table names to the list of tables to flush. Setting only_django to False will fix the issue since the introspection module will correctly list lal the tables.