Silver Light Silver Light - 1 year ago 158
SQL Question

How to TRUNCATE TABLE using Django's ORM?

To empty a database table, I use this SQL Query:


How to I truncate a table using Django's models and ORM?

I've tried this, but it doesn't work:


Answer Source

The closest you'll get with the ORM is Book.objects.all().delete().

There are differences though: truncate will likely be faster, but the ORM will also chase down foreign key references and delete objects in other tables.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download